简体   繁体   English

特殊字符“”在 Linux 中不起作用,转换为“?”

[英]special character “” is not work in Linux, converted into “?”

I consuming an api which is returning String with special characters, so I replace them with blank or some other user readable char.我使用了一个 api ,它返回带有特殊字符的字符串,所以我用空白或其他一些用户可读的字符替换它们。

My code:我的代码:

String text = response;
        if (text != null) {
            text = text.replace("Â", "");
            //same for other special char
        }

The above code works fine for windows machine but in Linux "Â" converted into "?", even other all special char converted into "?".上面的代码适用于 windows 机器,但在 Linux 中“”转换为“?”,甚至其他所有特殊字符都转换为“?”。 I am using Java, UTF-8 in my HTML.我在我的 HTML 中使用 Java、UTF-8。 Please let me know any platform independent solution.请让我知道任何独立于平台的解决方案。 Thanks谢谢

I am consuming the REST api, so while getting the output I have to maintain UTF-8 encoding.我正在使用 REST api,因此在获取 output 时,我必须保持 ZAE3B3ZEDF9970B49B68757575

BufferedReader br = new BufferedReader(new InputStreamReader((inputStream), standardCharsets.UTF_8));

I have added standardCharsets.UTF_8我添加了standardCharsets.UTF_8

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

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