我的项目中有一个问题是用 Java 字符串中的另一个 unicode 字符替换一个 unicode 字符。
在搜索和尝试不同的代码后,我没有找到解决方案,因为我想将波斯语中的一个字符替换为另一个具有不同 unicode 编号的波斯语字符。
非常感谢任何帮助。
谢谢
最佳答案
尝试此操作将解决您的问题。
str.replaceAll("\\p{Sc}", string_to_replcae);
示例如下:
String str = "For some reason my �double quotes� were lost.";
str = str.replaceAll("\uFFFD", "\"");
可以从这里查看此示例:How to replace � in a string
点击链接获取更多 unicode 表达式。 http://www.regular-expressions.info/unicode.html
关于java - 如何替换java字符串中的unicode字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23024609/