62,616
社区成员
发帖
与我相关
我的任务
分享
String input = new String(x.getBytes("utf-8"),"gbk");
Unicode Code UTF-8 Code
0000~007F 0xxxxxxx
0080~07FF 110xxxxx 10xxxxxx
0800~FFFF 1110xxxx 10xxxxxx 10xxxxxx
10000~10FFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
String bears = "三只小熊";
String x = new String(bears.getBytes("gbk"),"utf-8");
System.out.println(x);
String result = new String( x.getBytes("utf-8"), "gbk" );
System.out.println( "三只小熊".equals( result ));
String bears = "三只小熊";
String x = new String(bears.getBytes("gbk"), "utf-8");
System.out.println(x);
String result = new String(x.getBytes("utf-8"), "gbk");
System.out.println("三只小熊".equals(result));
public class TestEncodingString
{
public static void main( String[] args ) throws UnsupportedEncodingException
{
String bears = "三只小熊";
String x = new String(bears.getBytes("gbk"),"utf-8");
String result = new String( x.getBytes("utf-8"), "gbk" );
System.out.println( "三只小熊".equals( x ));
}
}