如何解析具有以这种方式编写的 unicode 字符的字符串:\u003C、\u0022
How do I resolve a string that has unicode characters written in that way: \u003C, \u0022
我有一个字符串,其中包含 \u0022
、\u003C
、\n
等子字符串,我想用它们所代表的字符替换它们。最直接的方法是什么?当然我可以做类似
code = code.replaceAll("\\u003C", "<");
每个这样的角色,但这有点烦人。
编辑: 为了说清楚,我已经有一个字符串像
code="Hello \u0022 World \n \u003C And so on.";
public static void main(String[] args) throws FileNotFoundException, IOException {
Properties properties = new Properties();
String str = "unicodedString=Hello \u0022 World \n \u003C And so on.";
StringReader stringReader = new StringReader(str);
properties.load(stringReader);
System.out.println(properties.getProperty("unicodedString"));
}
输出
Hello " World
< And so on.
我有一个字符串,其中包含 \u0022
、\u003C
、\n
等子字符串,我想用它们所代表的字符替换它们。最直接的方法是什么?当然我可以做类似
code = code.replaceAll("\\u003C", "<");
每个这样的角色,但这有点烦人。
编辑: 为了说清楚,我已经有一个字符串像
code="Hello \u0022 World \n \u003C And so on.";
public static void main(String[] args) throws FileNotFoundException, IOException {
Properties properties = new Properties();
String str = "unicodedString=Hello \u0022 World \n \u003C And so on.";
StringReader stringReader = new StringReader(str);
properties.load(stringReader);
System.out.println(properties.getProperty("unicodedString"));
}
输出
Hello " World
< And so on.