replace special characters in string in java

前端 未结 4 472
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 02:22

I want to know how to replace the string in Java.

E.g.

String a = \"adf�sdf\";

How can I replace and avoid special characters?

4条回答
  •  旧时难觅i
    2020-12-02 02:56

    You can use unicode escape sequences (such as \u201c [an opening curly quote]) to "avoid" characters that can't be directly used in your source file encoding (which defaults to the default encoding for your your platform, but you can change it with the -encoding parameter to javac).

提交回复
热议问题