Maven: Source Encoding in UTF-8 not working?

后端 未结 5 476
南旧
南旧 2020-12-13 03:38

i am converting a project from Ant to Maven and i\'m having problems with a specific unit test which deals with UTF-8 characters. The problem is about the following String:<

5条回答
  •  囚心锁ツ
    2020-12-13 04:29

    Your problem is not the encoding of the source file (and therefore the String inside your class file) but the Problem is the encoding of System.out's implicite PrintStream. It uses file.encoding which represents the System encoding, and this is in Windows the ANSI codepage.

    You would have to set up a PrintWriter with the OEM code page (or you use the class which is intended for this: Console).

    See also various bugs around this in: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4153167

提交回复
热议问题