Java tutorial
//package com.java2s; public class Main { public static int getStringLength(String value) { if (null == value || "".equals(value)) { return 0; } else { int valueLength = 0; String chinese = "[\u4e00-\u9fa5]"; for (int i = 0; i < value.length(); i++) { String temp = value.substring(i, i + 1); if (temp.matches(chinese)) { valueLength += 2; } else { valueLength += 1; } } return valueLength; } } }