Android examples for Internationalization:Chinese
get Chinese Char Length
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static String chineseEx = "[\\u4e00-\\u9fa5]"; public static float getChineseCharLength(String value) { float count = 0; Pattern p = Pattern.compile(chineseEx); Matcher m = p.matcher(value); while (m.find()) { for (int i = 0; i <= m.groupCount(); i++) { count++;/* www . java 2s . co m*/ } } count += 0.5f * (value.length() - count); return count; } }