10
回答
java 解析 unicode 字符
Recommend.cbRecoFittings({"master":{"name":"\u4e2d\u5174\uff08ZTE\uff09V882 3G\u624b\u673a\uff08\u9ed1\u8272\uff09WCDMA/GSM \u975e\u5b9a\u5236\u673a","price":"699.00","discount":"100.00","pic":"g8/M02/0F/09/rBEHaFCt4iQIAAAAAAE9JcQ33X4AAC_FgLyhx0AAT09916.jpg","skuid":"737667","sort":655},"fittings":[{"name":"\u98de\u6bdb\u817fSD-226\u79fb\u52a8\u7535\u6e90","price":"138.00","discount":"30.00","pic":"g7/M03/0C/0D/rBEHZlCEs2wIAAAAAACmRcgte8YAACbWACDKS0AAKZd963.jpg","skuid":737187,"sort":860},{"name":"","price":"199.00","discount":"0.00","pic":"g6/M01/01/00/rBEGDFCKWFwIAAAAAADVFe2mJ0kAAAMpAAqVgkAANUt527.jpg","skuid":751580,"sort":5270},{"name":"\u9ea6\u514b\u8d5b\u5c14\u667a\u80fd\u624b\u673a\u4e13\u7528\u8033\u673a \u9ed1\u8272 ","price":"79.00","discount":"30.00","pic":"g8/M03/03/0D/rBEHZ1A6zmQIAAAAAADjY1I2YuAAAAq6wC33t8AAON7213.jpg","skuid":603145,"sort":842},{"name":"\u7d22\u7231\uff08soaiy\uff09S-20 \u4fbf\u643a\u5f0f\u84dd\u7259\u6570\u7801\u63d2\u5361\u667a\u80fd\u97f3\u7bb1 \u9ed1\u8272","price":"399.00","discount":"0.00","pic":"g8/M03/09/05/rBEHZ1B-WO8IAAAAAAGELFIUem4AABysQLNzlIAAYRE427.jpg","skuid":745501,"sort":841},{"name":"\u9ea6\u514b\u8d5b\u5c14\u667a\u80fd\u624b\u673a\u4e13\u7528\u8033\u673a","price":"79.00","discount":"30.00","pic":"g7/M03/07/03/rBEHZlBYONkIAAAAAAC7drWlsccAABZAwLmmGMAALuO113.jpg","skuid":609211,"sort":842},{"name":"","price":"99.00","discount":"40.00","pic":"390/875b7f0c-19a0-49b6-8932-e63bdf8a12d2.jpg","skuid":437477,"sort":1219},{"name":"\u7ebd\u66fc\u79fb\u52a8\u7535\u6e90","price":"128.00","discount":"30.00","pic":"g5/M01/01/0F/rBEIDE_HOLYIAAAAAAC3R2i70FEAAASkgFUayYAALdf005.jpg","skuid":555061,"sort":1219},{"name":"uBay\u79fb\u52a8\u7535\u6e90","price":"99.00","discount":"70.00","pic":"g6/M03/01/13/rBEGDFCTLAYIAAAAAACvORuNxFMAAAUHAKVgi8AAK9R567.jpg","skuid":747912,"sort":1219},{"name":"10000\u6beb\u5b89\u79fb\u52a8\u7535\u6e90","price":"185.00","discount":"114.00","pic":"1193/8e742d45-ba90-41f6-82e2-0e79e128e254.jpg","skuid":585952,"sort":1219},{"name":"\u8003\u514b\u79fb\u52a8\u7535\u6e90","price":"189.00","discount":"110.00","pic":"g8/M03/0D/00/rBEHZ1COXFwIAAAAAADYnENRFCEAACimQPacYQAANi0899.jpg","skuid":730469,"sort":1219},{"name":"\u7ebd\u66fc\u79fb\u52a8\u7535\u6e90","price":"189.00","discount":"0.00","pic":"g7/M03/04/1A/rBEHZlA-4ZAIAAAAAAD40EetzhoAAA8YQCE7tkAAPjo177.jpg","skuid":717346,"sort":1219}],"fittingType":[{"sort":1219,"name":"\u79fb\u52a8\u7535\u6e90","number":6},{"sort":5270,"name":"\u82f9\u679c\u914d\u4ef6","number":1},{"sort":842,"name":"\u8033\u673a/\u8033\u9ea6","number":2},{"sort":841,"name":"\u97f3\u7bb1","number":1},{"sort":860,"name":"\u624b\u673a\u7535\u6c60","number":1}]})
这个是从京东商城上传回来的,这里面很多的unicode编码,怎么提取出来并且生成中文?
弄了一下午都没弄出来,烦啊!京东也真是的,怎么会弄个这玩意
举报
chworld
发帖于6年前 10回/1K+阅
共有10个答案 最后回答: 6年前
匹配\u 把匹配\\u([0-9a-f]{4})的后面四个字符取出来,前面拼上0x然后再用Integer按16进制转换。虽然我自己也觉得这样描述比较麻烦

用java提取。。。编码转不过来。

地址是这个:

http://d.360buy.com/fittingInfo/get?skuId=737667&callback=Recommend.cbRecoFittings

如果是js就好办了,可是工具是java!烦啊

引用来自“逝水fox”的答案

匹配\u 把匹配\\u([0-9a-f]{4})的后面四个字符取出来,前面拼上0x然后再用Integer按16进制转换。虽然我自己也觉得这样描述比较麻烦

这个拼上之后怎么用Integer转换成汉字?

String regex="\\\\u([0-9a-f]{4})";
			Matcher mt= Pattern.compile(regex).matcher(it);
			StringBuffer sb=new StringBuffer();
			while(mt.find()){
				sb.append(Integer.decode(("0x"+mt.group(1))));
				Util.println(sb);
			}
这样的结果:20013
2001320852
200132085265288
20013208526528865289


看别人有这么转换的。但是是将汉字转换成unicode 

public static String toUnicode(String s) {
	StringBuilder sb = new StringBuilder();
	for (int i = 0; i < s.length(); ++i) {
		if (s.charAt(i) <= 256) {
			sb.append("\\u00");
		} else {
			sb.append("\\u");
		}
		sb.append(Integer.toHexString(s.charAt(i)));
	}
	return sb.toString();
}

引用来自“逝水fox”的答案

匹配\u 把匹配\\u([0-9a-f]{4})的后面四个字符取出来,前面拼上0x然后再用Integer按16进制转换。虽然我自己也觉得这样描述比较麻烦

ok了,可以了!

Util.println((char )Integer.parseInt((mt.group(1)), 16));
中 兴(

引用来自“tianxiameng.com”的答案

native2ascii -reverse in.txt out.txt
这个只能在控制台转换吧?想在程序中转换。

引用来自“chworld”的答案

引用来自“tianxiameng.com”的答案

native2ascii -reverse in.txt out.txt
这个只能在控制台转换吧?想在程序中转换。
程序中可以调用控制台命令来进行转化的。
顶部