escape Code Point - Java java.lang

Java examples for java.lang:String Escape

Description

escape Code Point

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        CharSequence cs = "java2s.com";
        System.out.println(escapeCodePoint(cs));
    }/*from  w ww .j ava 2 s.c om*/

    private static String escapeCodePoint(CharSequence cs) {
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < cs.length(); ++i) {
            result.append(String.format("U+%04X", (int) cs.charAt(i)));
        }
        return result.toString();
    }
}

Related Tutorials