java unicode转码为中文实例
时间:2021-08-14 04:44:14
package com.infomorrow.parser_report;
import org.junit.Test;
public class Decode {
@Test
public void test(){
String uString = "\\u9053\\u8def";
System.out.println(ascii2native(uString));//道路
}
public static String ascii2native(String ascii) {
int n = ascii.length() / 6;
StringBuilder sb = new StringBuilder(n);
for (int i = 0, j = 2; i < n; i++, j += 6) {
String code = ascii.substring(j, j + 4);
char ch = (char) Integer.parseInt(code, 16);
sb.append(ch);
}
return sb.toString();
}
}
标签:unicode转码
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java实现带图形界面的聊天程序
2022-04-25 22:41:55
![](https://img.aspxhome.com/file/2023/5/71705_0s.jpg)
shiro整合springboot前后端分离
2022-02-22 10:40:31
Java的idea连接mongodb数据库的详细教程
2023-11-19 08:07:58
![](https://img.aspxhome.com/file/2023/1/59711_0s.png)
解决Mybatis的@Param()注解导致分页失效的问题
2022-05-01 13:24:53
![](https://img.aspxhome.com/file/2023/0/63400_0s.jpg)
Java数据结构及算法实例:冒泡排序 Bubble Sort
2022-10-17 08:39:45
java 中String.equals和==的比较
2023-03-09 08:45:16
Java多线程之读写锁分离设计模式
2021-06-08 07:20:48
Spring Cloud详解实现声明式微服务调用OpenFeign方法
2021-07-04 07:56:41
![](https://img.aspxhome.com/file/2023/3/68763_0s.png)
SpringBoot 文件上传和下载的实现源码
2021-05-28 14:12:46
![](https://img.aspxhome.com/file/2023/1/85531_0s.png)
Java实现简单学生管理系统
2023-01-06 16:40:38
![](https://img.aspxhome.com/file/2023/1/69901_0s.png)
java 类加载与自定义类加载器详解
2022-05-21 04:31:31
![](https://img.aspxhome.com/file/2023/4/92694_0s.png)
mybatis初始化SqlSessionFactory失败的几个原因分析
2021-06-17 11:13:44
![](https://img.aspxhome.com/file/2023/3/62083_0s.png)
MyBatis中${} 和 #{} 有什么区别小结
2021-09-21 14:42:35
![](https://img.aspxhome.com/file/2023/2/89572_0s.jpg)
MyBatis中使用$和#所遇到的问题及解决办法
2023-03-25 12:27:55
Spring Boot统一异常处理最佳实践(拓展篇)
2023-10-29 16:00:04
![](https://img.aspxhome.com/file/2023/6/61126_0s.png)
kafka消费不到数据的排查过程
2023-11-14 04:35:30
java算法题解牛客BM99顺时针旋转矩阵示例
2021-07-08 18:55:18
![](https://img.aspxhome.com/file/2023/3/80953_0s.jpg)
C#发送邮箱实现代码
2022-04-16 11:57:57
Java编程实现获取当前代码行行号的方法示例
2021-06-28 06:51:14
SpringBoot数据层测试事务回滚的实现流程
2022-05-01 14:36:37
![](https://img.aspxhome.com/file/2023/6/75776_0s.png)