How do I get the decimal value of a unicode character in Java? -


i need programmatic way decimal value of each character in string, can encode them html entities, example:

utf-8:

著者名 

decimal:

著者名 

i suspect you're interested in conversion char int, implicit:

for (int = 0; < text.length(); i++) {     char c = text.charat(i);     int value = c;     system.out.println(value); } 

edit: if want handle surrogate pairs, can use like:

for (int = 0; < text.length(); i++) {     int codepoint = text.codepointat(i);     // skip on second char in surrogate pair     if (codepoint > 0xffff)     {         i++;     }     system.out.println(codepoint); } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -