Converting UTF-8 to ISO-8859-1 in Java

后端 未结 4 1502
挽巷
挽巷 2020-12-08 11:45

I am reading an XML document (UTF-8) and ultimately displaying the content on a Web page using ISO-8859-1. As expected, there are a few characters are not displayed correctl

4条回答
  •  Happy的楠姐
    2020-12-08 12:15

    when you instanciate your String object, you need to indicate which encoding to use.

    So replace :

    return new String(latin1);
    

    by

    return new String(latin1, "ISO-8859-1");
    

提交回复
热议问题