Android String to UTF8 String Convert toGbk(String string)

Here you can find the source of toGbk(String string)

Description

to Gbk

Declaration

public static String toGbk(String string) 

Method Source Code

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EncodingUtils;

public class Main{
    public static String toGbk(String string) {
        String gbk = null;/*from   w w  w . ja  v a 2  s  .com*/
        try {
            gbk = URLEncoder.encode(string, "GBK");
        } catch (UnsupportedEncodingException e) {
        }
        return gbk;
    }
    public static String encode(String url) {
        if (StringUtil.isEmpty(url)) {
            return "";
        }
        String str = new String();
        try {
            str = URLEncoder.encode(url, HTTP.UTF_8);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return str;
    }
    public static boolean isEmpty(String paramString) {
        if ((paramString == null) || ("".equals(paramString))) {
            return true;
        }
        return false;
    }
}

Related

  1. toUtf8String(String s)
  2. toSemiangle(String src)
  3. toDBC(String input)