get Chinese string Length - Android Internationalization

Android examples for Internationalization:Chinese

Description

get Chinese string Length

Demo Code

public class Main {

  public static int getChineseLength(String value) {
    int valueLength = 0;
    String chinese = "[\u0391-\uFFE5]";
    for (int i = 0; i < value.length(); i++) {
      String temp = value.substring(i, i + 1);
      if (temp.matches(chinese)) {
        valueLength += 1;//from  w ww. ja  v a2  s. c  o m
      }
    }
    return valueLength;
  }

}

Related Tutorials