简体   繁体   中英

Encoding Special Characters in String

I have a String with some special characters like this one.

"45” £800 77” " - > might also have some other special chars

Note that above string its not double quotes.

I want to display the String as it is, but for some reason its not processing and i am not able to proceed further.

What is the best way to encode this ?

I have tried the below :

String out = null;
        try {
            out = new String(s.getBytes("UTF-8"), "ISO-8859-1");
        } catch (java.io.UnsupportedEncodingException e) {
            return null;
        }
        return out;

But it adds some special symbols to the specials chars.

I am trying to add this string in paypal payment screen , where we display item name.

试试这个,它可能对您有帮助,

tv.settext(Html.fromHtml("Your Text"));

看一下Apache Commons中的StringEscapeUtils.escapeJava之类的东西

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