开发者

Java - Evaluate String from String

in my Java code I have this snippet:

String str = "\\u9601";

But I want it to be:

String str = "开发者_如何学Python\u9601";

which represents a wide character.

Are there ways to do this?

Please help. Thanks in advance.

Supplementary:

Sorry for the badly-described question.

System.out.print("\u9601"); //this will display a Chinese character

I am currently request a webpage(URL) which response with a JSON. If dumped to Console using "System.out.print", the JSON will turn out to be 6 visible characters \, u, 9, 6, 0 and 1,but not a Chinese character in eclipse.

So actually what I want is are there APIs can convert "\\u9601" to "\u9601", since I can not hard code the Java source for the contents comes from website.


If you want it to be String str = "\u9601";, keep it that way!

Edit based on the updated question

The StringEscapeUtils.unescapeJava method in the Apache Commons Lang API should be of help:

    String str = "\\u9601";
    str = StringEscapeUtils.unescapeJava(str);
    System.out.println(str);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜