简体   繁体   English

如何替换java字符串中的unicode字符

[英]How can I replace a unicode character in java string

I have an issue in my project that is replacing a unicode charcter with another unicode character in a Java string.我的项目中有一个问题,就是用 Java 字符串中的另一个 unicode 字符替换 unicode 字符。 After searching and trying different codes , I did'nt get the solution for that I want to replace a character in Persian to another character in Persian with different unicode number.在搜索并尝试不同的代码后,我没有得到解决方案,因为我想将波斯语中的一个字符替换为具有不同 unicode 编号的波斯语中的另一个字符。 I really appreciate any help.我真的很感激任何帮助。

thanks谢谢

Trying this will solve your issue.试试这个会解决你的问题。

str.replaceAll("\\p{Sc}", string_to_replcae);

and example can be like below:示例如下:

String str = "For some reason my �double quotes� were lost.";
    str = str.replaceAll("\uFFFD", "\"");

this example can be viewed from here : How to replace � in a string这个例子可以从这里查看: How to replace � in a string

follow the link for more unicode expressions.点击链接了解更多 unicode 表达式。 http://www.regular-expressions.info/unicode.html http://www.regular-expressions.info/unicode.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM