\X开头的编码转为汉字的几种方式 |
您所在的位置:网站首页 › x开头的警员编号代表什么 › \X开头的编码转为汉字的几种方式 |
概念
\x开头的编码是十六进制字符,\x后面跟的字符即为十六进制的字符串。 解码方式将\x转为中文的几种方式: 1 在linux客户端通过命令echo -e 输出 [root@localhost ~]# echo -e '\xe9\xa3\x8e\xe5\xa5\xb3\xe9\x83\x8e' 风女郎2 将替换为%,使用UrlDecoder工具进行解码 转\x为%得到 \xe9\xa3\x8e\xe5\xa5\xb3\xe9\x83\x8e %e9%a3%8e%e5%a5%b3%e9%83%8e 找一个urldecoder在线工具进行解析。eg:http://www.jsons.cn/urlencode/![]() 3 JAVA解码 package com.tjh.encryption.utils.encodedecode; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; /** * @auth tangjianghua * @date 2021/2/24 */ public class Hex2Str { public static String hex2UTF8(String hexStr) throws UnsupportedEncodingException { return URLDecoder.decode(hexStr.replaceAll("\\\\x", "%"), StandardCharsets.UTF_8.name()); } public static String hex2GBK(String hexStr) throws UnsupportedEncodingException { return URLDecoder.decode(hexStr.replaceAll("\\\\x", "%"), "gbk"); } public static void main(String[] args) throws Exception{ String utf8String = "\\xe9\\xa3\\x8e\\xe5\\xa5\\xb3\\xe9\\x83\\x8e"; System.out.println(hex2UTF8(utf8String)); } }console: 风女郎 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |