Java 한글 인코딩 안될때 jdk 버전 확인해야함.
배경
IDE 에서는 한글이 잘 출력되는데,
java 소스코드(System.out.println)를 통해서 출력시 글자가 깨지는 현상.
원인
JEP-400(인코딩이 default 로 UTF-8 로 설정되는 기능)이 jdk 18 버전에서 문제를 일으키는 것으로 확인. (Windows 환경)
해결방안
jdk 버전을 17 이하 버전을 사용할 것.
참고
https://inside.java/2021/10/04/the-default-charset-jep400/
Jep 400 and the default charset – Inside.java
Have you ever wondered what is `default charset`? Here’s what the javadoc for Charset.defaultCharset says…
inside.java
https://bugs.eclipse.org/bugs/show_bug.cgi?id=579383
579383 – [18] encoding proeblem: utf-8 output of Java 18 not shown correctly in Console
simple utf-8 encoded Java program which produces utf-8 output with germen umlauts no flags Details
bugs.eclipse.org
Java JDK 18 in IntelliJ prints question mark "?" when I tried to print unicode like "\u1699"
tldr: I downgraded to JDK 17 (17.0.2) and now it works... I was watching a beginners Java tutorial by Kody Simpson on YT (youtube.com/watch?v=t9LP9Nt9Nco), and in that tutorial the boy Kody prints ...
stackoverflow.com