import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
public class Test {
public static void main(String[] args) {
String str = "测试字符转换 hello word"; //默认环境,已是UTF-8编码
try {
String strGBK = URLEncoder.encode(str, "GBK");
System.out.println(strGBK);
String strUTF8 = URLDecoder.decode(str, "UTF-8");
System.out.println(strUTF8);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
Android 中文字符转UTF-8编码
最新推荐文章于 2022-10-21 16:09:25 发布