简体   繁体   English

从文件读取后,特殊字符未正确填充

[英]special characters are not getting populated correctly after reading from file

InputStreamReader isr = new InputStreamReader(new FileInputStream(f), "UTF-8");

According to rule it should return all specified characters as it is in stream. 根据规则,它应返回流中的所有指定字符。 But it is not working fine. 但它不能正常工作。 It is converting special characters into some invalid character strings. 它将特殊字符转换为一些无效的字符串。

Input characters : éÇüéâäàåçêëèïîìÄÅÉæ 输入字符:

output after reading from above method : 从上述方法读取后输出:

This means that your stream is not in UTF-8. 这意味着您的流不在UTF-8中。 It may be in Windows-1252 or ISO 8859-1 or some other encoding. 它可能是Windows-1252或ISO 8859-1或其他某种编码。

The reader needs to use the encoding that the stream is encoded with, in order to read it properly. 读者需要使用流编码所使用的编码,以便正确读取它。

Article worth noting: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) 值得注意的文章: 绝对绝对是每个软件开发人员绝对必须了解的Unicode和字符集(无借口!)

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

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