c语⾔utf8字符转换,C语⾔⽰例-中⽂转换成UTF-8编码
/** 中⽂字符串转UTF-8与GBK码⽰例
*/
public static void tttt() throws Exception {
String old = “⼿机银⾏”;
//中⽂转换成UTF-8编码(16进制字符串)
StringBuffer utf8Str = new StringBuffer();
byte[] utf8Decode = Bytes(“utf-8”);
for (byte b : utf8Decode) {
utf8Str.HexString(b & 0xFF));
}
/
/ String()=====e6898be69cbae993b6e8a18c
// System.out.println(“UTF-8字符串e6898be69cbae993b6e8a18c转换成中⽂值======” + new String(utf8Decode, “utf-8”));//——-⼿机银⾏
c语言中文网汇编语言//中⽂转换成GBK码(16进制字符串)
StringBuffer gbkStr = new StringBuffer();
byte[] gbkDecode = Bytes(“gbk”);
for (byte b : gbkDecode) {
gbkStr.HexString(b & 0xFF));
}
// String()=====cad6bbfad2f8d0d0
// System.out.println(“GBK字符串cad6bbfad2f8d0d0转换成中⽂值======” + new String(gbkDecode, “gbk”));//———-⼿机银⾏
//16进制字符串转换成中⽂
byte[] bb = String());
bb = HexString2Bytes(“CAD6BBFAD2F8D0D0000000000000000000000000”);
byte[] cc = hexToByte(“CAD6BBFAD2F8D0D0000000000000000000000000”, 20);
String aa = new String(bb, “gbk”);
System.out.println(“aa====” + aa);
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。