Android Utililty Methods String to UTF8 String Convert

List of utility methods to do String to UTF8 String Convert

Description

The list of methods to do String to UTF8 String Convert are organized into topic(s).

Method

StringtoUtf8String(String s)
to Utf String
StringBuffer sb = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
    char c = s.charAt(i);
    if (c >= 0 && c <= 255) {
        sb.append(c);
    } else {
        byte[] b;
        try {
...
StringtoSemiangle(String src)
to Semiangle
char[] c = src.toCharArray();
for (int index = 0; index < c.length; index++) {
    if (c[index] == 12288) {
        c[index] = (char) 32;
    } else if (c[index] > 65280 && c[index] < 65375) { 
        c[index] = (char) (c[index] - 65248);
return String.valueOf(c);
StringtoDBC(String input)
to DBC
char[] c = input.toCharArray();
for (int i = 0; i < c.length; i++) {
    if (c[i] == 12288) {
        c[i] = (char) 32;
        continue;
    if (c[i] > 65280 && c[i] < 65375)
        c[i] = (char) (c[i] - 65248);
...
StringtoGbk(String string)
to Gbk
String gbk = null;
try {
    gbk = URLEncoder.encode(string, "GBK");
} catch (UnsupportedEncodingException e) {
return gbk;