1.首先springboot项目中引入
hutool
pom
依赖
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.5.8</version>
</dependency>
//第二个参数true表示跳过ASCII字符(只跳过可见字符)
String s = UnicodeUtil.toUnicode(“aaa123中文”, true);
//结果aaa123\u4e2d\u6587
String str = “aaa\U4e2d\u6587\u111\urtyu\u0026”;
String res = UnicodeUtil.toString(str);
//结果aaa中文\u111\urtyu&