import java.io.UnsupportedEncodingException;
public class Test {
public static String getCode(String content, String format) throws UnsupportedEncodingException {
byte[] bytes = content.getBytes(format);
StringBuffer sb = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
sb.append(Integer.toHexString(bytes[i] & 0xff).toUpperCase() + " ");
}
return sb.toString();
}
public static void main(String[] args) throws UnsupportedEncodingException {
System.out.println("gbk : " + getCode("张", "gbk"));
System.out.println("gb2312 : " + getCode("张", "gb2312"));
System.out.println("iso-8859-1 : " + getCode("张", "iso-8859-1"));
System.out.println("unicode : " + getCode("张", "unicode"));
System.out.println("utf-16 : " + getCode("张", "utf-16"));
System.out.println("utf-8 : " + getCode("张", "utf-8"));
}
}
gbk : D5 C5 gb2312 : D5 C5 iso-8859-1 : 3F unicode : FE FF 5F 20 utf-16 : FE FF 5F 20 utf-8 : E5 BC A0
public class Test {
public static void main(String[] args) {
String str = "张";
}
}
public class Test {
public static void main(String[] args) {
String str = "张";
System.out.println(Integer.toHexString(str.codePointAt(0)).toUpperCase());
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有