이 글의 문맥을 분석하여 이글루스에 있는 많은 글 중에서 관련성이 높은 글을 자동으로 검색해 낸 결과입니다.
choiwonwoo.egloos.com
U a Thinking? U a Dream? D a Passion?

개발자마을

by choiwonwoo
카테고리
My Story & Article
My Thi/Dre/Pas
Dev Article
Dev Information(C#)
Dev Reference Site
Dev Security
Dev Web
Dev Tool
Dev Database
Dev Network
DEV C
Dev Linux
ServerDevResource
JAVA
Powered by egloos
rss

skin by 이글루스
Egloos | Log-in
한글문제

컴퓨터 속에서 맨날 한글을 봐오고 있으면서도 막상 한글 코드에 대해서 관심 있어 하는 프로그래머는 그리 많지 않은 듯 싶다. 그리고 관심을 가진다고 해도 잘 정리된 문서가 없는 듯 싶어서 내가 아는 내용을 살짝 정리해 봅니다.

우선 한글은 조합형, 완성형, 확장 완성형, iso2022-kr, unicode 등으로 표현이 가능하며… 조합형, 완성형, 확장 완성형, iso2022-kr 등은 symbol table 과 한자 테이블 또한 가지고 있지만 여기서 관련된 내용은 거의 얘기하지 않을 겁니다.

  1. 조합형 (Johab)

    ASC II 범위에 있는 글자는 그대로 프린트하고 한글인 경우 MSB 를 1로 세팅하고 나머지 비트를 초성(5bit) / 중성(5bit) / 종성(5bit) 을 표현하는데 사용한다. 이론 상으로 한글 11172 자를 모두 표현해낼 수 있으며 한글 입력을 처리하기가 아주 쉽다. 다만 Microsoft 에서 완성형을 선택함에 따라 잊혀진 인코딩이 되어가고 있다.

  2. 완성형 (EucKR)

    ksx1001 에 정의되어 있으며 역시나 ASC II 범위의 글자는 그대로 프린트 한다. 한글의 경우 연속된 두 개의 바이트를 이용해서 표현하게 되며 첫번째 바이트와 두번째 바이트 모두 0xA1~0xFE 사이의 값을 가진다.

    한글은 2350 자 밖에 지원하지 않지만 MS windows 에서 선택함에 따라 널리 사용되고 있다.

  3. 확장완성형 (Unified Hangul Code)

    Microsoft 에서 EucKR 에 몇 가지 글자를 더 추가한 인코딩으로 UHC, cp949 등으로도 불린다. 빈 공간에 글자를 추가해 넣었기 때문에 바이너리 값 그대로 정렬을 시도할 경우 한글의 가나다라 순서대로 정렬되지 않는 문제가 있다.

    EucKR 과 마찬가지로 한글을 표현하는데는 2바이트를 사용하며 첫번째 바이트는 0×81~FE 사이 두번째 바이트는 0×41~5A, 0×61~7A, 0×81~FE 영역을 차지한다.

  4. iso2022-kr

    EucKR 을 7bit 만 사용하며 표현하는 방식으로 RFC1557 에 정의되어 있다. Designator Sequence (0×1B 24 29 43), SO (0×0E), SI (0×0F) 등을 이용해 EucKR 을 7bit 로 변환시킨다.

    Designator sequence 는 non ASC character 를 만나기 전에 아무 때나 한 번만 나와주면 되며, non asc character 를 만나면 SO 를 출력 후 다시 asc character 를 만날 때까지 0×7F 와 AND 연산을 해서 출력한다. (MSB 를 reset) 그러다가 asc character 를 만나게 되면 SI 를 찍고 나서 다음 글자들을 프린트하면 된다. 이런 과정을 반복하면 EucKR 은 iso2022-KR 로 변환된다.

    그 과정을 pseudo code 로 표현하자면 (위에 설명이 좀 복잡하게 보이는데 실제로 보면 간단하다.)

    print 0x1B 0x24 0x29 0x43 // Designator Sequencestats = ascwhile( char = get_next_char() ){    if( stats == asc ){        if( char & 0x80 ){            print 0x0E // SO            stats = non_asc        }    }    else{        if( !(char & 0x80) ){            print 0x0F // SI            stats = asc        }        else            char &= 0x7F;    }    print char}

    (위의 pseudo code 에서는 Designator Sequence 를 맨 앞에 출력을 했지만 iconv 등에서는 처음으로 non asc character 를 만났을 때 출력하고 있다.)

위의 네가지 인코딩 이 그동안 많이 쓰여왔던 인코딩 들인데 국제화 시대인 지금은 오로지 한글만을 표현할 수 있는 저런 인코딩으로는 뭔가 부족하다. 그렇기 때문에 유니코드 콘소시움에서는 여러가지 언어를 함께 표현할 수 있도록 unicode 라는 글자집합(character set)을 만들어 냈으며, 유니코드를 표현하는 5가지의 encoding 을 제공하고 있다. (ucs2, ucs4, utf-7, utf-8, utf-16)

  1. ucs2

    2바이트 고정형 인코딩, unicode 와 4.0 버젼과 동일하다. Endian 관련해서 Big Endian 과 Little Endian 으로 표현이 가능하다.

  2. ucs4

    4바이트 고정형 인코딩. 길이를 제외하곤 ucs2 와 거의 동일하다.

  3. utf-7

    unicode 의 mail safe version. RFC1642 에 정의되어 있다. BASE64 와 비슷한 방식을 통해 unicode 를 7bit 로 표현하게 된다.

  4. utf-8

    가변형 인코딩으로 1바이트영역은 Asc II 와 100% 호환된다. 0×00 이 사용되지 않으므로 전통적으로 C 언어에서 사용해온 null terminated 방식을 사용하는데 문제가 없고 2바이트 이상을 사용하는 경우 특수한 규칙을 가지고 있기 때문에 validation 이 가능하다.

  5. utf-16

    ucs2 와 ucs4 를 적절하게 혼합해서 사용하는 방식으로 BMP (Basic Multilingual Plane) 에 들어있는 글자는 2 바이트로 표현하게 되고 그 외의 글자들은 4 바이트를 이용해서 표현하게 된다.

utf-7 과 utf-8 을 제외하고는 byte order 가 중요시 되기 때문에 BOM(Byte Order Mark) 를 문서 맨 앞에 삽입해야 한다. 그렇기 때문에 Unicode 로 작성된 텍스트 파일의 경우 BOM 을 이용해 어떤 인코딩을 사용하는 지지 알아내는게 가능하다. (utf-8 을 위한 BOM 도 존재하지만 utf-8 의 경우 Byte Order 가 정해져 있기 때문에 BOM 을 의무적으로 삽입할 필요는 없다.)

EncodingUTF-8UTF-16BEUTF-16LEUTF-32BEUTF-32LE
‘가’EA B0 80AC 0000 AC00 00 AC 0000 AC 00 00
Smallest code point00000000000000000000
Largest code point10FFFF10FFFF10FFFF10FFFF10FFFF
Code unit size8 bits16 bits16 bits32 bits32 bits
Byte orderN/Abig-endianlittle-endianbig-endianlittle-endian
Byte order markEF BB BFFE FFFF FE00 00 FE FFFF FE 00 00
Minimal bytes12244
Maximal bytes44444

대강 ucs2, ucs4, utf-8, utf-16, utf-32 의 특징을 정리하면 위의 표와 같다. UTF-8 의 경우엔 ASC II 와 호환이 되기 때문에 영어권 언어들에서 별다른 조작 없이도 문제를 일으키지 않게 되므로 널리 쓰이고 있다. UTF-8 과 UCS2 사이의 변환은 아래와 간단한 규칙을 통해 이루어지게된다.

  1. 0×00~0×7F 까지는 그냥 표시한다.
  2. 0×80~07FF 까지는 B110xxxxx 10xxxxxx (2바이트)
  3. 0×0800-FFFF 까지는 B1110xxxx 10xxxxxx 10xxxxxx (3바이트)
  4. 이후는 UCS4 영역이고 위와 같은 방식으로 4바이트까지 확장됩니다.

보다시피 ASC II 는 그대로 표현하고 있습니다. 그리고 2바이트 이상을 사용하는 문자에서는 2진수 기준으로 앞에 붙어있는 1의 개수가 그 글자를 표시하는데 사용된 바이트 수를 나타내며, 2번째 바이트부터는 맨 앞에 10 을 붙여줌으로 이건 글자의 시작이 아니라는 걸 표시하게 됩니다. 위의 두 규칙을 지키면서 unicode 를 2진수로 바꾸어 xx 로 표시된 영역에 차례로 배치하게되면 ucs -> utf-8 변환은 끝이 납니다. 한글은 UTF-8 로 표현하게 될 경우 한 글자 당 3 바이트 씩을 차지하게 됩니다.

그리고 이 유니코드에서 한글이 차지하는 영역은 아래와 같습니다.

  1. U+1100: 조합형 영역

    첫가끝 코드라는 이름으로도 불리고 있으며 초성(첫), 중성(가운데), 종성(끝)이 각기 다른 영역에 배치되어 있다. 이 영역에 있는 글자들을 이용하면 한글 고어까지도 표현이 가능해진다.

    한글 한 글자를 표현하는데 많은 저장공간이 필요하다는 점과, iconv 에서 첫가끝 영역 -> Euc-KR, iso2022-kr, UHC 로의 변환이 불가능한 점 등이 약간의 문제라고 생각됨.

  2. U+3130: 한글 자모 영역

    ㄱ,ㄴ,ㄷ,ㄹ, … , ㅏ,ㅑ,ㅓ,ㅕ, … 등의 자음과 모음이 배치되어 있는 영역

  3. U+AC00: 완성형 영역

    가각… 같이 이미 완성되어 있는 한글 케릭터가 11172 자 배치되어 있다.

# by choiwonwoo | 2007/07/26 12:40 | Dev Web | 트랙백(64) | 덧글(0)
트랙백 주소 : http://choiwonwoo.egloos.com/tb/1364196
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
Tracked from Forced sex f.. at 2008/08/11 13:14

제목 : Free forced sex movies.
Forced sex videos. Forced sex stories. Free forced sex stories. Forced sex fantasy storie. Forced sex. Forced sex dvds videos scenes....more

Tracked from Cash advance.. at 2008/08/16 11:23

제목 : Cash advance loan oregon.
Does loan officers analyze cash. Quick cash loan www.thepayloan.com....more

Tracked from Quick cash p.. at 2008/08/16 20:17

제목 : Fast cash loan wisconsin.
Axcess cash pay day loan. Cash advance loan. Car title cash loan nebraska. Bad credit fast cash loan. Cash loan oregon. Fast cash advance payday loan. Quick cash loan www.thepayloan.com. Real estate loan calculator cash flow analyzer....more

Tracked from A payday cas.. at 2008/08/18 07:57

제목 : Cash loan illinois.
500net advance cash loan payday. Car title cash loan nebraska. Quick cash loan www.thepayloan.com....more

Tracked from Payday loan .. at 2008/08/19 10:28

제목 : Faxless payday loan.
Payday loan az. Payday loan reviews. Loan payday. Payday loan. National payday loan com. Payday loan oregon. Instant payday loan....more

Tracked from Free nokia r.. at 2008/08/20 07:16

제목 : Ringtones.
Totally free ringtones. Free alltel ringtones. Download free ringtones. Ringtones....more

Tracked from Free rington.. at 2008/08/20 20:40

제목 : Ringtones for motorola.
Free verizon ringtones. Free ringtones. Free ringtones samsung. Free motorola ringtones. Ringtones....more

Tracked from Airline last.. at 2008/08/21 06:24

제목 : Airline ticket.
Airline ticket seattle wa. Airline cheap dirt ticket. Airline fare low manila ticket. Airline ticket for under 100. Airline ticket. Airline ticket to hawaii. Airline cheap discount military ticket....more

Tracked from Buy percocet. at 2008/08/21 18:46

제목 : I quit percocet.
Percocet dosing. Compare brand name and generic percocet. Percocet. Identify a percocet 93-490. Percocet effects....more

Tracked from Ativan xanax.. at 2008/08/22 16:48

제목 : Xanax effect.
Generic xanax no prescription. Xanax xr crushed. Xanax. Uhi foundation forums xanax cheap phentermine. Xanax side effects. Xanax weight gain....more

Tracked from Ambien. at 2008/08/26 06:28

제목 : Ambien overnight.
Ambien side effects....more

Tracked from Cheapest tra.. at 2008/08/26 17:10

제목 : Tramadol cod.
Tramadol....more

Tracked from Wellbutrin i.. at 2008/08/27 04:14

제목 : Wellbutrin sr.
Wellbutrin side effects. Anxiety and wellbutrin. Wellbutrin together with ambien suicide. Wellbutrin and alcohol. Wellbutrin effects depression rxlist. Wellbutrin. Seroquil wellbutrin....more

Tracked from Comments on .. at 2008/08/27 16:34

제목 : Propecia specifications.
Propecia. Reversing the effects of propecia. Propecia result. Generic propecia. Propecia dosage. Cheap propecia buy propecia online....more

Tracked from Viagra on li.. at 2008/08/28 04:47

제목 : Viagra.
Viagra. Viagra patent. Free viagra....more

Tracked from Instant payd.. at 2008/08/28 18:16

제목 : Payday loan facts.
Payday loan wisconsin. Payday advance loan utah. American payday loan websites. Payday loan. Is there a way out of the payday loan cycle. Illinois payday loan. Payday advance loan oregon....more

Tracked from Canadian pre.. at 2008/08/29 06:52

제목 : Side effects of percocet.
Can you snort percocet. Identify a percocet 93-490....more

Tracked from Dangers of v.. at 2008/08/29 18:34

제목 : How long does vicodin stay i..
Addiction vicodin. Vicodin. Long term vicodin use. Buying vicodin online....more

Tracked from Generic fior.. at 2008/08/30 07:25

제목 : Fioricet.
Fioricet prescription. Fioricet. Fioricet cod. Buy fioricet online that ships to missouri. Cheapest fioricet....more

Tracked from Cash loan ma.. at 2008/08/31 20:47

제목 : Quick cash loan illinois.
Advance cash loan tennessee. Quick cash loan utah. World wide cash and loan. Cash loan. Cash advance loan oregon....more

Tracked from Ambien and t.. at 2008/09/01 10:40

제목 : Ambien.
Ambien message board. Ambien....more

Tracked from Quick cash l.. at 2008/09/01 22:46

제목 : Cash loan wisconsin.
Cash advance loan wisconsin. Quick cash loan www.thepayloan.com....more

Tracked from Fioricet. at 2008/09/02 11:31

제목 : Fioricet antidepressants.
Buy fioricet bloghoster. Fioricet. Cheap fioricet. Advanced book by fioricet guest powered. Cheapest fioricet. Fioricet long term use damage....more

Tracked from Ultram er. at 2008/09/02 23:25

제목 : Ultram.
Ultram. Ultram er. Order ultram no prescription. Ultram drug abuse. Celebrex as well as ultram gt online medications....more

Tracked from Payday advan.. at 2008/09/04 06:24

제목 : Payday loan.
Payday loan....more

Tracked from Continental .. at 2008/09/04 20:11

제목 : Cheap airline tickets.
Airline tickets. Discount airline tickets. Continental airline tickets. Cheap airline tickets....more

Tracked from Ripped fuel .. at 2008/09/05 23:26

제목 : Ephedra is it legal.
Ephedra is it legal. Ephedra....more

Tracked from Fioricet mes.. at 2008/09/06 13:34

제목 : Fioricet.
Fioricet. Advanced book by fioricet guest powered. Cheapest fioricet. Order fioricet cash on delivery....more

Tracked from Cash loan or.. at 2008/09/08 19:37

제목 : Fast cash advance payday loan.
Cash advance loan illinois. Bad credit cash loan. Quick cash loan www.thepayloan.com. Cash advance loan wisconsin. Cash loan military....more

Tracked from Dirt cheap a.. at 2008/09/10 20:27

제목 : Cheap airline tickets.
Airline tickets. Cheap airline tickets....more

Tracked from Does fiorice.. at 2008/09/12 01:02

제목 : Fioricet.
Fioricet prescription. Fioricet. Fioricet side effects. Hard to talk and fioricet codeine. Fioricet message board....more

Tracked from Ratio of tra.. at 2008/09/13 19:04

제목 : Tramadol.
Buy tramadol. Tramadol hcl liquid. Tramadol....more

Tracked from Cash loan. at 2008/09/14 05:05

제목 : Advance cash illinois loan 5.
Unsecured long term cash loan. Quick cash loan www.thepayloan.com. Fast cash loan utah. Cash advance loan wisconsin....more

Tracked from Airline tick.. at 2008/09/15 10:50

제목 : Discounted airline tickets.
Discount airline tickets....more

Tracked from Valium. at 2008/09/15 22:59

제목 : Valium without prescription.
Valium abuse. Valium withdrawal. Valium....more

Tracked from Wellbutrin. at 2008/09/16 12:07

제목 : Wellbutrin xl.
Anxiety and wellbutrin. Celexa lexapro wellbutrin. Provigil wellbutrin lexapro. Wellbutrin and seizures....more

Tracked from Nextel ringt.. at 2008/09/17 03:49

제목 : Free mobile ringtones.
Free ringtones. Alpha kappa alpha ringtones....more

Tracked from Soma. at 2008/09/18 08:54

제목 : Soma online sales.
Soma triathlon. Soma. Soma online....more

Tracked from Diabetes one.. at 2008/09/18 20:48

제목 : Soma without prescription.
Soma radio. Soma cube. Soma compound. Soma to florida. Soma. Buy soma online. Coupons for soma by chicos....more

Tracked from Cheapest fio.. at 2008/09/20 12:44

제목 : Fioricet online.
Fioricet. Advanced book by fioricet guest powered....more

Tracked from Generic prop.. at 2008/09/20 23:30

제목 : Propecia online uk.
Propecia blood pressure. Propecia. Pill propecia. Proscar versus propecia. Side effects of propecia finasteride mg. Combining results of propecia and rogain....more

Tracked from Free rington.. at 2008/09/21 11:56

제목 : Free mp3 ringtones.
Download free ringtones. Free ringtones samsung. Free virgin mobile ringtones. Christian ringtones. Ringtones. Free polyphonic ringtones....more

Tracked from Xanax. at 2008/10/30 23:59

제목 : Xanax 2mg.
Buy xanax online. Xanax. Xanax online....more

Tracked from Yellow jacke.. at 2008/11/05 23:03

제목 : Stacker with ephedra.
Ephedra products. Ephedra based. Liquid ephedra. Ephedra ban illegal to posses. Ephedra. Diet fuel ephedra....more

Tracked from Prevacid iv .. at 2008/11/09 04:12

제목 : Prevacid.
Prevacid side affects. Prevacid prilosec side effects....more

Tracked from Purchase pre.. at 2008/11/15 17:43

제목 : Prednisone side effects.
Prednisone in children. Prednisone. Prednisone works. Warnings side effects of prednisone. Purchase prednisone. Prednisone side effects....more

Tracked from Cialis 20mg. at 2008/11/16 10:02

제목 : Cheap cialis.
Cialis generic click here. Cialis. Cialis fedex. Multiple orgasms through cialis....more

Tracked from Xanax. at 2008/11/17 13:39

제목 : Xanax withdrawal symptoms.
Xanax during pregnancy....more

Tracked from Buy carisopr.. at 2008/12/01 21:45

제목 : Buy carisoprodol.
Carisoprodol side effects. Carisoprodol. Carisoprodol phentermine yellow. Carisoprodol addiction....more

Tracked from Cialis soft .. at 2009/04/23 20:21

제목 : Cialis soft.
Cialis soft tabs. Cialis soft tab buy cialis generic cialis uk. Cialis soft....more

Tracked from Animal sex w.. at 2009/04/24 01:33

제목 : Animal sex.
Animal sex pictures animal....more

Tracked from No prescript.. at 2009/04/24 17:19

제목 : No prescription generic vali..
Valium without prescription. No prescription needed for valium. No prescription valium. Valium prescription online. Buy valium without prescription....more

Tracked from Viagra for s.. at 2009/04/24 21:59

제목 : By mail sale viagra.
By mail sale viagra. Viagra sale....more

Tracked from Cheap xanax .. at 2009/04/27 01:46

제목 : Xanax online no prior perscr..
Order xanax online. Xanax online. Buy xanax online shipped overnight. Buy xanax online no rx. Xanax without a prescription best online pharmacy. Buying xanax online....more

Tracked from Natural viag.. at 2009/04/28 01:13

제목 : Natural viagra alternatives.
Natural viagra. Natural viagra alternatives....more

Tracked from Tramadol mep.. at 2009/04/28 03:36

제목 : Carisoprodol soma drug test.
Pdr carisoprodol soma. Carisoprodol soma drug test. Soma carisoprodol you can found more info here. Soma carisoprodol abuse information. Get soma carisoprodol to effectively relieve pain. Tramadol meprobamate carisoprodol soma drug test....more

Tracked from Purchase via.. at 2009/04/28 19:34

제목 : Cheap online purchase viagra.
Purchase viagra online. Cheap online purchase viagra....more

Tracked from Ultram wont .. at 2009/04/30 07:53

제목 : Tramadol brand s ultram defi..
Ultram drugs amp vitamins drug library drugdigest. Ultram wont make you fail a drug test....more

Tracked from Mature hardc.. at 2009/05/01 09:37

제목 : Hardcore rough sex.
Hardcore teen sex. Britney spears- hardcore sex. Hardcore lesbian sex. Hardcore sex....more

Tracked from Long term si.. at 2009/05/01 17:55

제목 : Xanax side effects.
Side effects of drug xanax. Side effects of xanax....more

Tracked from Phentermine .. at 2009/05/02 06:50

제목 : Phentermine on line without ..
Phentermine no prescription. Phentermine without a prescription. Discount phentermine without a prescription. Buy phentermine online without prescription cheap. Phentermine on line w o prescription. Phentermine no prescription outside us. No prescrip......more

Tracked from Side effects.. at 2009/05/03 20:38

제목 : Phentermine side effects.
Phentermine side effects. Side effects phentermine cheap phentermine online....more

Tracked from Ultram er. at 2009/05/04 09:34

제목 : Ultram er mg.
Ultram er....more

Tracked from Klonopin. at 2009/05/13 09:54

제목 : Buy klonopin online without ..
Klonopin and alcoholic. Klonopin. Long term effects of klonopin. Buy klonopin online without a prescription. Lethal dose klonopin....more

:         :

:

비공개 덧글

< 이전페이지 다음페이지 >


이글루링크 추가하기
()을(를)
이글루링크로 추가하시겠습니까? 추가하시려면 그룹선택을 하세요.
(그룹선택 하지 않는 경우, 최상단 목록에 추가됩니다.)
그룹선택 :
이글루링크 취소