본문 바로가기

[IT/Programming]

터미널 (Terminal) | Cmd (Command|커맨드) 창 | Sublime text build results 창 에서의 한글 깨짐 해결 방법. (Windows)

반응형
# 터미널 (Terminal) | Cmd (Command|커맨드) 창 | Sublime text build results 창 에서의 한글 깨짐 해결 방법. (Windows) 한글이 깨지는 이유는 주로 한글 팩 (Package) 가 윈도우 (Windows) 에 안깔려 있거나, 한글을 나타내주는 폰트 (font) 가 없거나, 인코딩 (Encoding) 이 잘못되어 있는 경우 중 한가지다. 개인적으론 AWS English Windows server 를 돌리면서 Sublime text 로 runJavaC.sublime-build 로 Compile 및 실행|Run 했을때 Build results 에서 한글이 계속 ?? ?? ????????? 로만 표시되길래 고생해서 해결방법을 찾아서 공유하려고 이 글을 작성. ## PH
  • 2023-09-25 : First posting.
## TOC ## runJava.bat and runJavaC.sublime-build 아래가 runJava.bat 파일 내용 : ```[.linenums.lang-bat] @REM encoding must be EUC-KR with Korean folder name. @ECHO OFF :: destination of class to be created SET DC=C:\Recoeve\classes :: The whole CLASSPATH list splited by ";" @REM SET CLASSPATH=.;%JAVA_HOME%\lib;%RECOEVE_CLASS%\classes;%RECOEVE_CLASS%\classes\javax.mail.jar;%RECOEVE_CLASS%\classes\mysql-connector-j-8.0.33.jar;%RECOEVE_CLASS%\classes\activation-1.1.1.jar;%VERTX_HOME%\conf;%VERTX_HOME%\lib\* :: %~nx1 expands %1 [arg 1] to "file name + extension". e.g. "HelloWorld.java" ECHO Compiling %~nx1 :: Compile %~nx1 with {filename:%~nx1, encoding:UTF-8, destination:%DC%, classpath:%CLASSPATH%} javac %~nx1 -encoding UTF-8 -d "%DC%" -classpath "%CLASSPATH%" IF NOT %ERRORLEVEL%==0 GOTO :EOF :: source directory SET SD=%CD% @REM or SET SD=%~dp1 :: %SD%\%~n1 gives [source directory]\file_name. e.g. "C:\Recoeve\sources\kipid\hello\HelloWorld". SET packSD=%SD%\%~n1 @REM or SET packSD=%~dpn1 :: Replace "C:\Recoeve\sources\" to "" [empty] of %packSD%. e.g. "kipid\hello\HelloWorld". SET CN=%packSD:C:\Recoeve\sources\=% :: Replace "\" to "." of %cn%. e.g. "kipid.hello.HelloWorld" :: This is a class name with JAVA package included. SET CN=%CN:\=.% ECHO --- OUTPUT: %CN% %2 %3 %4 %5 %6 %7 %8 %9 --- :: Change directory to the %DC% [destination of class to be created]. CD %DC% :: Run/Execute the class created. java -Dfile.encoding=UTF-8 -classpath "%CLASSPATH%" %CN% %2 %3 %4 %5 %6 %7 %8 %9 :: Back to source directory CD %SD% ```/
아래가 runJavaC.sublime-build 파일 내용 : ```[.linenums.lang-json] { "cmd": ["runJava.bat", "$file"] // , "file_regex": "^(...*?):([0-9]*):?([0-9]*)" , "selector": "source.java" , "encoding": "utf-8" // "cp949" } ```/ ## Build results of Sublime text 한글이 출력되는 곳에 ``` ?? ?? ??????? ????????? ```/ 와 같이 물음표로 표시되거나 이상한 문양으로 출력되는 경우가 있었는데, 윈도우에 언어팩도 안깔려 있었고, 인코딩 (Encoding) 도 일치하지 않아서 발생한 문제였음. ## Windows language settings (위도우 언어 설정) 다국어 지원을 위해서는 UTF-8 인코딩 (Encoding) 을 사용하는 것이 좋은데, 대부분의 한글 윈도우 (Windows) 는 기본적으로 cp949euc-kr 인코딩 (Encoding) 을 쓰는 경우가 많다. 영어 윈도우 (English Windows) 의 경우도 인코딩 (Encoding) 을 UTF-8 을 안쓰는 경우가 많은것 같은데 윈도우 언어 설정 및 인코딩 (Encoding) 을 UTF-8 로 바꾸는 방법에 대해 알아봅시다.
우선 시간 및 언어 (Timezone and Language) 설정에 들어가서 기본 언어 설정 을 클릭하면 작은 창이 뜹니다. 여기서 시스템 로캘 변경 을 클릭한 뒤,
Beta: 세계 언어 지원을 위해 Unicode UTF-8 사용을 체크하시고 확인을 누르신 뒤 시스템을 다시 시작하라고 뜨면 지침에 따라서 윈도우를 다시시작 (Windows restart) 하면 이제 인코딩 (Encoding) 을 UTF-8 로 곳곳에서 바꾸시면 한글이 제대로 뜰 겁니다.
한글 기본 Encoding 이 UTF-8 이 아니다 보니 이 UTF-8 로 짠 한글로된 프로그램은 한글이 또 깨져보일수가 있음. 이건 어쩔수 없는거 같음. 이 회사들이 UTF-8 Encoding 으로 다시 프로그래밍을 해주길 바라는 수밖에 =ㅇ=;;;
## RRA
  1. Installing and Learning JAVA at kipid.tistory.com
반응형