Helius
2021-01-18 fc46f2a7c6680df278f4c68c5e91a0ce544a2de4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.matrix.component.ueditor;
 
public class Encoder {
 
    public static String toUnicode ( String input ) {
        
        StringBuilder builder = new StringBuilder();
        char[] chars = input.toCharArray();
        
        for ( char ch : chars ) {
            
            if ( ch < 256 ) {
                builder.append( ch );
            } else {
                builder.append( "\\u" +  Integer.toHexString( ch& 0xffff ) );
            }
            
        }
        
        return builder.toString();
        
    }
    
}