简体   繁体   中英

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. It may be in Windows-1252 or ISO 8859-1 or some other encoding.

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!)

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