let str = '中文内容' //待转换中文
escape(str ).replace(/(%u)(\w{4})/gi, "$2")
UTF-8转中文:
let str = '徐恒' //待转换UTF-8
unescape(str .replace(//g, '%u').replace(//g, ''))
java不同编码之间进行转换,都需要使用unicode作为中转。以utf-8转gbk为例,示例代码如下: String t = "这是一个字符串aaa111" String utf8 = new String(t.getBytes( "UTF-8")) System.out.println(utf8) String unicode = new String(utf8.getBytes(),"UTF-8") System.out.println(unicode) String gbk = new String(unicode.getBytes("GBK")) System.out.println(gbk)