> ## Content Index
> Fetch the complete content index at: https://www.popit.kr/llms.txt
> Use this file to discover other available public pages before exploring further.

# 글라발라이제이션 - 문자 세트 및 인코딩
- URL: https://www.popit.kr/globalization-charset-encoding-euckr/
- Published: 2016-09-01T15:05:04.000Z
- Updated: 2016-09-02T15:54:44.000Z
- Author: sql2
- Tags: #소프트웨어, putty, encoding, i18n, globalization, ko_KR, utf8, euckr, locale, localedef, iconv, characterset

컴퓨터는 미국이 만들었다!! ASCII 는 쉽다!! 그러나, 우린 한국인이다!! ㅠㅠ

영어는 LTR 이다!! 한국어도 LTR 이다!! 그러나, 난 영어를 못한다!! ㅠㅠ

그런데, 나보고 RTL 을 지원하라고 한다?! ㅠㅠ

> [http://en.wikipedia.org/wiki/Bi-directional\_text](http://en.wikipedia.org/wiki/Bi-directional%5Ftext?ref=popit.kr)

![locale](https://mysqlko.files.wordpress.com/2016/08/locale.png?w=680)

### 

### **0\. 글로발제이션!!**

우리는 영어권이 아님에도 불구하고, 저를 포함해서 많은 개발분들이 i18n 이슈에 대해서 잘 모르고 있습니다. 글자가 깨지거나, 제대로 출력되지 않을 때에 참으로 곤란합니다. 제대로 출력이 되었어도, 제대로 인코딩이 되었는지 보장되기 어렵습니다.

> [http://en.wikipedia.org/wiki/Internationalization\_and\_localization](http://en.wikipedia.org/wiki/Internationalization%5Fand%5Flocalization?ref=popit.kr)

이런 어려움에 도움이 되실지 몰라서 정리해보았습니다.

### **1\. 로케일 환경변수 ( Locale Environment Variables )**

기본 시스템의 locale 에서 korean 와 LCID ( Locale ID ) 지원여부를 확인하고, 만약에 설치가 안되어 있다면 localedef ( locale-gen ) 커맨드로 추가해주시면 됩니다. 그리고, shell 에 맞게 export or set 으로 환경변수를 설정해주시면 되니다.

> [http://www.microsoft.com/resources/msdn/goglobal/default.mspx](http://www.microsoft.com/resources/msdn/goglobal/default.mspx?ref=popit.kr)

> $ locale -a | grep ko\_KR  
>  
>  
>  
> ko\_KR  
>  
> ko\_KR.euckr  
>  
> ko\_KR.utf8  
>  
> $ localedef -f UTF-8 -i ko\_KR ko\_KR.UTF-8  
>  
> $ export LANG = ko\_KR.utf8  
>  
> $ export LC\_ALL= ko\_KR.utf8

### **2\. 터미날 케릭터셋 ( Terminal Characterset )**

Terminal 의 characterset 을 shell 환경변수와 동일하게 맞추어 줍니다. Putty 의 경우에는 기본적으로 UTF-8 를 포함하여 30여가지 characterset 을 내장하고 있습니다. 그러나, 영문 공식 Putty 에서 지원하지 않는 characterset 을 사용하여 한다면?! 어떻게 해야할까요?!

> [http://www.chiark.greenend.org.uk/\~sgtatham/putty/download.html](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html?ref=popit.kr)

다음과 같이 2가지 방법이 있습니다.

1. 소스를 수정하여 내가 직접 캐릭터셋을 추가한다.
2. **Google 님께 소원을 빈다. 누군가가 이미...**

공식 홈페이지 링크를 참고하시거나, 구글링하셔서 구하시면 됩니다. **단언컨데, Putty 보다 완벽하게 캐릭터셋을 지원하는 Terminal Emulator 는 없습니다. 단, 그 언어를 쓰는 엔지니어, 개발자, 키보드가 있을 때에만...**

> [http://www.chiark.greenend.org.uk/\~sgtatham/putty/links.html](http://www.chiark.greenend.org.uk/~sgtatham/putty/links.html?ref=popit.kr)  
>  
>  
>  
> Internationalised and localised versions :  
> PuTTYjp, with ISO-2022 support and other things Japanese  
> PuTTY DBCS Patched, with a Chinese feel  
> Arabeyes PuTTY, a project to add Arabic support to PuTTY (this code is now included in our releases)  
> iPuTTY/HangulPuTTY, an internationalised fork with an emphasis on Korean support  
> Polish localised version of PuTTY (no source)

**Putty -> Windows -> Translation -> UTF-8**

![SNAG-0001 2016-08-30 오후 9.19.07](https://mysqlko.files.wordpress.com/2016/08/snag-0001-2016-08-30-ec98a4ed9b84-9-19-07.png)

### **3\. 폰트 ( Font )**

그리고, 매우 중요한! Font 도 설정해주셔야 합니다. 이 부분을 모르시는 분이 상당히 많아서 해당 나라/언어 Window 를 설치하시는 경우도 있습니다. 그냥, 언어지원하는 Font 만 설치하시면 됩니다. ( 간혹 MS Window 에서 실행되는 프로그램의 경우는 MS AppLocale, LanguagePack 으로도 문제가 되는 경우가 있기 때문에 해당 나라별 Window 를 설치하는 경우도 있습니다. )

**Putty -> Window -> Appearance -> Font**

![SNAG-0002 2016-08-30 오후 9.20.10](https://mysqlko.files.wordpress.com/2016/08/snag-0002-2016-08-30-ec98a4ed9b84-9-20-10.png)

**글꼴 -> 굴림체 -> 스크립트 -> 한글**

![SNAG-0003 2016-08-30 오후 9.20.38](https://mysqlko.files.wordpress.com/2016/08/snag-0003-2016-08-30-ec98a4ed9b84-9-20-38.png)

**글꼴 -> Courier New -> 스크립트 -> 영어**

![SNAG-0004 2016-08-30 오후 9.20.52](https://mysqlko.files.wordpress.com/2016/08/snag-0004-2016-08-30-ec98a4ed9b84-9-20-52.png)

그렇다면, **CJK ( China Japan Korea )** 중국어는?! 일본어는?!

역시 Google 님께 Font 은총을 내려 달라고 기도합니다.

> [http://www.google.com/get/noto](http://www.google.com/get/noto?ref=popit.kr)

### **4\. 파일 인코딩 ( File Encoding )**

File Encoding 을 확인하여 합니다. 100% 신뢰하기는 어려울 수도 있습니다. 다국어 ( multilingual ) 를 포함할 경우, 이상한 값들이 포함된 경우가 있기 때문입니다. 추가적으로 file type 에 따라서 BOM ( Byte Order Mark ) 등을 체크해볼 필요가 있습니다.

> $ file text.txt  
>  
>  
>  
> text.txt: UTF-8 Unicode text

file command 로 확인이 어렵거나, 애매할 때, 혹은 전혀 모르는 언어와 인코딩으로 되어 있어 있을 경우에는 어떻게 해야 하나!?

이럴쭐\~ 알고\~ 내가 준비했지!!

이런 고민은 우리가 매일같이 쓰고 있는 Web Brower 에서 이미 끝난 얘기입니다. ( 그러나, 100% 는 불가능?! )

> mozilla  
>  
>  
>  
> [http://www-archive.mozilla.org/projects/intl/chardet.html](http://www-archive.mozilla.org/projects/intl/chardet.html?ref=popit.kr)  
>  
> [https://en.wikipedia.org/wiki/Charset\_detection](https://en.wikipedia.org/wiki/Charset%5Fdetection?ref=popit.kr)  
>  
> [https://wiki.kldp.org/wiki.php/%B1%E8%C1%A4%B1%D5/CharDet](https://wiki.kldp.org/wiki.php/%B1%E8%C1%A4%B1%D5/CharDet?ref=popit.kr)

Python chardetect 2.2.1

> $ chardetect text.txt  
>  
>  
>  
> text.txt: utf-8 with confidence 0.7525

그리고, 원하는 인코딩이 아닐 경우에는 어떻게 해야 하나!? convert 해주면 된다. 그리고, 같은 characterset 으로 convert 함으로써 characterset valid 를 할 수 있습니다.

> $ iconv -l | grep UTF-8  
>  
>  
>  
> $ iconv -f EUC-KR -t UTF-8 -o utf8.txt text.txt  
>  
> $ iconv -f UTF-8 -t UTF-8 -o utf8.txt text.txt

### **5\. 에디터 인코딩 ( Editor Encoding )**

Editor Encoding 설정을 해줘야 합니다. 만약에 vim 이 지원안하다면?! 다른 Editor 를 써야 합니다.

> [http://vimdoc.sourceforge.net/htmldoc/mbyte.html](http://vimdoc.sourceforge.net/htmldoc/mbyte.html?ref=popit.kr)

> $ vim $HOME/.vimrc  
>  
>  
>  
> set encoding=utf8  
>  
> set fileencoding=utf8

RTL ( Right To Left ) Language 라면 ?!

> :set rightleft

### **6\. 한국사람 인코딩 ( Korean Encoding )**

마지막으로 한국어를 읽기쓰기가 가능한 사람이 필요합니다! 만약에 없다고 한다면, Hex Dump 를 해서 값들을 체크하고, Google Translate 를 통해서 확인하는 방법도 있습니다.

그러나, 1회성이나 단순한 문장이면 모르겠지만, 해당 언어와 문화를 아는 사람이 필요합니다.

## hello. 안녕하세요. こんにちは。

> [https://translate.google.co.kr/#en/ja/hello.](https://translate.google.co.kr/?ref=popit.kr#en/ja/hello.)