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编码
猜你喜欢
转载自blog.csdn.net/lpcrazyboy/article/details/80451995
今日推荐
周排行