/*
* unicode编码转中文
*/
public static String decodeUnicode(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') {
// Read the xxxx
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;
接口返回值中文是unicode字符,转中文
最新推荐文章于 2023-09-09 16:42:09 发布
这篇博客主要讨论了如何将接口返回的Unicode字符转换为中文。示例中展示了转换前后的JSON数据,其中"info"字段从Unicode的'u83b7u53d6u6210u529f!'转换为了'获取成功!',同时描述了如何处理类似的数据字段。
订阅专栏 解锁全文
1099

被折叠的 条评论
为什么被折叠?



