How to find the first Chinese character in a java string -
how find first chinese character in java string example:
string str = "xing 杨某某";
how can index of first chinese character 杨 in above str. thanks!
this help:
public static int firstchinesechar(string s) { (int = 0; < s.length(); ) { int index = i; int codepoint = s.codepointat(i); += character.charcount(codepoint); if (character.unicodescript.of(codepoint) == character.unicodescript.han) { return index; } } return -1; }
Comments
Post a Comment