Android examples for Internationalization:Chinese
is String encoded in GBK
import android.text.TextUtils; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static boolean isGBK(String str) { char[] chars = str.toCharArray(); boolean isGBK = false; for (int i = 0; i < chars.length; i++) { byte[] bytes = ("" + chars[i]).getBytes(); if (bytes.length == 2) { int[] ints = new int[2]; ints[0] = bytes[0] & 0xff; ints[1] = bytes[1] & 0xff; if (ints[0] >= 0x81 && ints[0] <= 0xFE && ints[1] >= 0x40 && ints[1] <= 0xFE) { isGBK = true;/*w w w .j a va 2 s . c o m*/ break; } } } return isGBK; } }