How do I make eclipse print out weird characters in unicode?

前端 未结 3 1607
情深已故
情深已故 2021-02-09 07:41

So I\'m trying to make my program output a text file with a list of names. Some of the names have weird characters, such as Åström.

I have grabbed these list of names fr

3条回答
  •  半阙折子戏
    2021-02-09 08:04

    The content is indeed in UTF-8 and it appears OK if printed to the console. What may be causing the problem is the decoding and encoding of the string which is unnecessary. Instead of an OutputStreamWriter try using a java.io.PrintWriter. It has the println methods that print out the string with the system line separator at the end. It would look something like:

    printStream.println(list.get(i));
    

    Also, when opening the file to see it try using a browser. They allow you to choose the encoding after opening it so you can try several encodings quickly to see what is being really used.

提交回复
热议问题