[英]How can i replace every emoji in a string with their unicode in java?
[英]How can I replace a unicode character in java string
我的项目中有一个问题,就是用 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.