在编码字符串中的特殊字符

在编码字符串中的特殊字符

问题描述:

我有一些特殊字符,像这样的一个字符串。

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.

什么是EN code呢?

What is the best way to encode this ?

我已经试过如下:

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.

看看像 StringEscapeUtils.escapeJava 来自Apache下议院

have a look at something like StringEscapeUtils.escapeJava from Apache Commons