我在Java字符串中遇到西班牙字符问题。我在文件中有内容,当我尝试使用InputStreamReader将其转换为java对象时,某些字符串的输出为“cÃmo”,应为“cómo”。这是发生在其他西班牙语

á=á
é=é
í= í
ó=ó
ú=ú

和更多..

您能否帮助我将其转换为适当的输出。

提前致谢

最佳答案

您是否尝试过在InputStreamReader的构造函数中指定字符编码,如下所示:

FileInputStream fis = new FileInputStream("file.txt");
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");

10-07 19:07
查看更多