问题描述
- 在JAVA如何将ASCII码转为utf输出到一个文本文档中?
-
各位大神,情况是这样的,领导交代我一直在爬网,现在已经爬到了回复处,在各位大神的帮助下,小弟已经找到了回复的源码,不过源码却是ASCII格式的,请问如何将其转换为utf格式,方便存入文本文档中。源码如下:
这是一个回复内容数据:
u975eu5e38u4e0du9519u7684u4e00u7bc7u6587u7ae0uff0cu5e72u8d27uff0cu5e72u8d27u3002u628au793eu4ea4u8fd0u8425u8bb2u7684u900fu5f7bu3002
这个全部回复JS的相应数据:
{"errno":0,"data":{"hasmore":true,"comments":[{"user_name":"Fei52012345","user_pic":"http://tb.himg.baidu.com/sys/portraitn/item/e8474665693532303132333435da38","user_type":"0","ts":"1431394929000","id":"507196","text":"u975eu5e38u4e0du9519u7684u4e00u7bc7u6587u7ae0uff0cu5e72u8d27uff0cu5e72u8d27u3002u628au793eu4ea4u8fd0u8425u8bb2u7684u900fu5f7bu3002","from":"weibo","support_count":"1","vip_intro":"","format_ts":"23u5206u949fu524d"},{"user_name":"u5584u826fu7684u5e73u6c11","user_pic":"http://tb.himg.baidu.com/sys/portraitn/item/21e0c9c6c1bcb5c4c6bdc3f11228","user_type":"0","ts":"1431394912000","id":"507198","text":"u6709u601du60f3uff01u900fu8fc7u73b0u8c61u770bu5230u672cu8d28uff01u73b0u5728u7684u98ceu6c14u5c31u662fu592au6d6eu4e86uff0cu8ba4u4e3au81eau5df1u53efu4ee5u4f5cu4efbu4f55u4e8buff0cu4efbu4f55u90fdu53efu80fdu6210u529fuff0cu5728u9047u5230u95eeu9898u4e4bu524du5c31u8ba4u4e3au81eau5df1u7684u60f3u6cd5u548cu4f5cu6cd5u662fu771fu7406uff01","from":"weibo","support_count":"0","vip_intro":"","format_ts":"23u5206u949fu524d"}],"ts":"1431327560000"}}
解决方案
这是 json 格式的数据啊。用 org.json 包就行了。会自动转义的。
解决方案二:
使用gson.jar包就行了,会自动帮你转的~
时间: 2024-08-24 13:21:10