在Java程序中总会出现\u6b22\u8fce\u63d0\u4ea4\u5fae\u535a\u641c\u7d22\u4f7f\u7528\u53cd\u9988\uff0c\u8bf7\u76f4\u63a5这个的字符,这是unicode编码,使用时有时候不会自动转换成中文就需要自己转换了使用下面的方法转换一下即可。
/** * unicode 转换成 中文 * @author fanhui 2007-3-15 * @param theString * @return */ public static String decodeUnicode2(String theString) { char aChar; int len = theString.length(); StringBuffer outBuffer = new StringBuffer(len); for (int x = 0; x < len;) { aChar = theString.charAt(x++); if (aChar == '\\') { aChar = theString.charAt(x++); if (aChar == 'u') { int value = 0; for (int i = 0; i < 4; i++) { aChar = theString.charAt(x++); switch (aChar) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': value = (value << 4) + aChar - '0'; break; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': value = (value << 4) + 10 + aChar - 'a'; break; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': value = (value << 4) + 10 + aChar - 'A'; break; default: throw new IllegalArgumentException( "Malformed \\uxxxx encoding."); } } outBuffer.append((char) value); } else { if (aChar == 't') aChar = '\t'; else if (aChar == 'r') aChar = '\r'; else if (aChar == 'n') aChar = '\n'; else if (aChar == 'f') aChar = '\f'; outBuffer.append(aChar); } } else outBuffer.append(aChar); } return outBuffer.toString(); }
相关推荐
中文转化为unicode格式的方法类,经过程序验证完全可使用。
excel 公式 自动转换unicode编码为汉字
在eclipse编辑struts2 资源文件的插件 ,能把资源文件由unicode转换成中文
Java中文成Unicode码及从Unicode码转成中文
汉字unicode转换器,方便汉字和UNICODE之间转换!
只要安装了jdk,都可以转换的简单windows命令,中文转Unicode码和Unicode码转中文,简单、方便、实用。
这个时候搜索内存时 就需要把汉字转换成unicode的形式 这个小工具就能帮上大忙了。。 注意这个版本有点小问题 就是初始化的时候显示我信息的Unicode 没有。这是我调试时候方便 在初始化窗口的时候注释掉了。。其它...
unicode 汉字转换器 unicode 汉字转换器 基于java编写,是个jar包,安装jdk后,直接双击
汉字Unicode转换器,汉字Unicode可以相互转换
unicode汉字转换unicode汉字转换unicode汉字转换unicode汉字转换unicode汉字转换
Notepad++(UNICODE)简体中文
实现Unicode和汉字的互相转码,解压后excel文档直接转换,方便快捷。
该工具支持汉字和unicode之间的相互转换器
汉字与unicode转换工具
Unicode和中文的相互转换——VS2019的C++控制台项目(x64\x86\Debug\Release已编译) 1. bool ChineseToUnicode(CString cstr, string & str); 望断秋高和待雪初平__ChineseToUnicode:\u671b\u65ad\u79cb\u9ad8\u...
有的时候,遇见中文都被转化成了Unicode内码,看着很不爽,于是写了这么个小工具,用来将Unicode内码转换为中文,可以实现整篇的转换。 另外,此工具也可以将中英文转换为Unicode内码(您可以选择是否将英文转换)...
unicode和中文互相转换工具,支持不同编码格式。
Unicode编码所有汉字,解压后打开cmd程序,电脑必须安装java
个人编写的C#版16进制unicode字符和汉字想换转换的工具,涵盖源码,可以直接运行
可以直接在c语言中使用,数组左列为unicode,根据unicode的数值大小从小到大进行排序,右列为对应的GB2312编码,旁边有注释对应的汉字,亲测可以在单片机上使用,建议用二分法搜索unicode然后转换为GB2312。...