简体   繁体   中英

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. 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. 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

follow the link for more unicode expressions. http://www.regular-expressions.info/unicode.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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