문자 인코딩 관련

문자, 바이트, 문자열
       ,                  。         ,         :
  :       ,          。    :'1', ' ', 'a', '$', '¥', ……
  :           ,  8      ,           。     :0x01, 0x45, 0xFA, ……
ANSI   :    ,  “  ”   ANSI        ,                    ,            ANSI            。     :"  123"( 7  )
unicode   :    ,  “  ”    UNICODE        ,            UNICODE            。    :L"  123"( 10  )
    ANSI             ,  ,             ,                  ,           “  ”。    UNICODE      ,        ,     “  ”       。

문자 세트, 인코딩, 디코딩
              ANSI      ,            “  ”。  :    (GB2312)              。   ANSI                :
      。        ,            。   “  ”      “   ”。
    “  ”               ,        ,       “  ”。
                 ,“     ” “  ”         。  ,       “   ”,  :GB2312, GBK, JIS  ,   “     ”     ,      “  ”   。
        ISO-8859-1(  Latin-1)           ,            UNICODE   。  ,[0xD6, 0xD0]      ,   iso-8859-1        ,      [0x00D6, 0x00D0]    UNICODE   ,  "ÖÐ"。  ,  UNICODE       iso-8859-1        ,       0~255      。
ANSI    GB2312,BIG5,Shift_JIS,ISO-8859-2 ……   UNICODE       ANSI      “   ” ,         ,   UNICODE                 。  ,           ,              。  ,[0xD6, 0xD0]      ,   GB2312        ,    [0x4E2D]     ,  ' '  。
“ANSI   ”   :
1.   “ANSI     ”               UNICODE   。
2. “UNICODE   ” “       ”           。
UNICODE      UTF-8,UTF-16, UnicodeBig ……     “ANSI   ”   ,       UNICODE      “   ” ,   UNICODE                 。
 “ANSI   ”    :
1.   “UNICODE   ”        UNICODE   。
2. “UNICODE   ” “       ”            。
       ,                   。

ASCII 코드
    ,      ,                    。        (bit) 0 1    ,              256   ,        (byte)。    ,            256       ,           ,  256   , 0000000 11111111。
    60  ,           ,               ,      。    ASCII ,      。
ASCII      128      ,    "SPACE" 32(   00100000),     A 65(   01000001)。 128   (  32            ),           7 ,    1      0。

GB2312,BIG5,GBK
        7  ASCII  ,      ,             GB2312        BIG5。GB2312(1980 )     7445   ,  6763    682     。            B0-F7,    A1-FE,      72*94=6768。   5    D7FA-D7FE。
GB2312       。1995        GBK1.0   21886   ,            。     21003   。
 ASCII、GB2312 GBK,            ,                    ,            。      ,            。                   0。        ,GB2312、GBK          (DBCS)。

ANSI
ANSI(American National Standard Institite)      ,Internet        ——ANSI ASCII   ,   7bits       ,    128   ,         、  、         。  ,     ,  8 bits      ,    256   ,      7 bits                     。
  ,         ,ASCII             ,  ,             ,   ASCII             ,   ANSI               ANSI   ,          MBCS(Multi-Byte Chactacter System,        )。            ASCII 127 bits   ,  ASCII 127,      128       Leading Byte,   Leading Byte    (    )    Leading Byte         。         ,     GB-2312      。

                ,                ,                  。  ,   Unicode   ,     16bits(    、   )       ,     65536   。                   ,       。   Unicode  UTF-16。        Unicode                   ,   UTF-8,    MBCS    Unicode    。  UTF-8   ,   Unicode   。Unicode          , ASCII    ,   MBCS(  GB-2312)     。
Unicode     ,  1 16        65000      。     ,             ,           (implantation head-ache's)             。                16    。  ,Unicode                   。     UTF-8,UTF-16 UTF-32。      , UTF-8 ,    8       ,               。         , UTF-8   ASCII            ,  , UTF-8 ASCII ,“A”     0x41.UTF-16 UTF-32   Unicode 16  32     。        ,    Unicode   UTF-16。
    ANSI    ,0x00~0x7F(      0 127)     ,   1     1   。
    ASNI   Unicode             。

인코딩, code page
                    。
  Windows       Unicode   ,                    。                           ,  GBK,Windows           ,     Unicode。
Windows     (code page)          。code page             。GBK   code page CP936。    GB18030   code page:CP54936。
   (Code Page)         ,   IBM       。              ,                  ,        。                    。
Windows                。     936       GBK,   950       Big5。          ,          。

유니버설이란?
Unicode(   、   、   )                ,     、     。Unicode                      ,
                           (     ),    ,           (   )     ,          (      、    、    、   )         ,              。      、         、     。

UTF-8이란?
UTF “Unicode Transformation Format”   ,     Unicode       ,    Unicode            。UTF-8、UTF-16、UTF-32                 。
UTF-8(8-bit Unicode Transformation Format)     Unicode         。
UTF-8       Unicode    。 Unicode UTF-8       :

Unicode  (    ) UTF-8    (   )
00000000 - 0000007F 0xxxxxxx
00000080 - 000007FF 110xxxxx 10xxxxxx
00000800 - 0000FFFF 1110xxxx 10xxxxxx 10xxxxxx
00010000 - 001FFFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
00200000 - 03FFFFFF 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
04000000 - 7FFFFFFF 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
       Unicode  :\u0000~\u007F(0~127)
       Unicode  :\u0080~\u07FF(128~2047)
       Unicode  :\u0800~\uFFFF(2048~65535)
       Unicode  :\u10000~\u1FFFFF(65536~2097151)
127、2047、66535、2097151          ?  UTF-8           0、110、1110 ,  1~4    UTF-8         7、11、16、21。
UTF-8                     。  0x00-0x7F     ,UTF-8   ASCII      。UTF-    8        6   。       ,6     31 x,     31      。Unicode     0x7FFFFFFF   31 。
 1:“ ”  Unicode   0x6C49。0x6C49 0x0800-0xFFFF  ,   3     :1110xxxx 10xxxxxx 10xxxxxx。 0x6C49      :0110     1100 0100 1001,               x,  :11100110 10110001 10001001, E6 B1 89。
 2:Unicode  0x20C30 0x010000-0x10FFFF  ,   4     :11110xxx 10xxxxxx 10xxxxxx    10xxxxxx。 0x20C30  21      (  21      0):0 0010 0000 1100 0011 0000,              x,  :11110000     10100000 10110000 10110000, F0 A0 B0 B0。

크기
             ?           ,          ,              ,      8bit。   C     8bit char  ,  16bit short ,32bit long (        ),  ,       8     ,  16   32     ,             ,                     。                   。    16bit short x,        0x0010,x   0x1122,  0x11    ,0x22    。       ,  0x11      , 0x0010 ,0x22      , 0x0011 。    ,    。     X86       , KEIL C51      。   ARM,DSP      。  ARM                       。
0000430: e684 6c4e 0100 1800 53ef 0100 0100 0000
      , 32      : e6 84 6c 4e (   int 4   )
      , 32      : 4e 6c 84 e6(   int 4   )

utf-8 바이트 시퀀스 없음
UTF-8        ,        ,                  ,         。        ,                , endian  。  GBK        ,           。            ,  CPU      。UTF-16      word(   ),word             ,word           endian   。UTF-8        ,CPU        。UTF-16          ,CPU        (      short     ,0000430: e684 6c4e,  CPU     0xe6846c4e,  CPU     0x4e6c84e6,  0xe6846c4e 0x4e6c84e6      ,     BOM , UTF-8    ,         ,           ,         UTF-16           ,      ,       。)
            ,                                 。
EF BB BF        UTF-8
FE FF           UTF-16/UCS-2, little endian
FF FE           UTF-16/UCS-2, big endian
FF FE 00 00     UTF-32/UCS-4, little endian.
00 00 FE FF    UTF-32/UCS-4, big-endian.

UCS 및 유니버설
unicode2.0    ISO 10646      . 
 unicode  ,iso          ,iso    ISO/IEC 10646  ,   “ Universal Multiple-Octet Coded Character Set”,  UCS。
  ,           2       ,          , unicode2.0 ,unicode    ucs        。
unicode     UCS    ,          , UCS        。unicode        UTF-8,UTF-16,UTF-32,  UTF-7 。UCS         :UCS-2 UCS-4  。
unicode      UCS-2 UCS-4    。       。UTF-16 UCS-2   ,UTF-32 UCS-4   。    ,UTF-16     code point       UCS-2, UTF-32 code point      UCS-4     。
  ,Unicode    , UTF-8    ,UCS        UTF-16,UTF-32 ,    UCS          。(Windows NT    UCS-2)。

UCS-2 및 UTF-16
UTF-16 UCS-2  Unicode     。
Unicode                (code point)          。  ©      “copyright   sign”       U+00A9(0xA9,   169)   。
Unicode     U+0000 U+10FFFF,  1,112,064   (code point)       . Unicode         17   (plane),      216(  65,536)   。            U+xx0000 U+xxFFFF,   xx        0016  1016,  17   。
   Unicode  (   U+0000 U+FFFF)         ,             (Basic Multilingual    Plane),   BMP。          (Supplementary Planes)。
UCS-2 (2-byte Universal Character Set)          ,UCS-   2         16        ,     0 0xFFFF      ,  UTF-16    。
UTF-16 (16-bit Unicode Transformation Format) UCS-2   ,     BMP     。UTF-   16        16         ,      0 0x10FFFF       。
  , UCS-2 UTF-16 ,BMP    U+00A9 copyright sign(©)     0x00A9。
   BMP     ,  ��,   UTF-16    ,    16      :0xD834  0xDF06。       ,                   ,     。UCS-2         ,    0xD834 0xDF06       。
    ,UTF-16    UCS-2   。         (surrogate code points) ,UTF-16 UCS-   2         。(         ,   UTF-16  U+D800 U+DFFF           ,    UCS-  2   ,U+D800 U+DFFF      。)           ,   UTF-16 。   
    Windows  16bit   Unicode   UTF-16,  UCS-2。       。
UCS-2       ,             Unicode  。 UCS-2     U+0000 U+FFFF BMP(Basic Multilingual Plane )     Unicode    ,     Unicode  , UTF-16    ,   UTF-  8   ,            ,  BMP          ,                     Unicode,     U+0000   U+10FFFF。

http://bbs.chinaunix.net/thread-1680943-2-1.html http://blog.csdn.net/ultrani/article/details/8432767 http://blog.163.com/lipse_huang/blog/static/191657545201261211330814/ http://www.fmddlmyy.cn/text6.html http://www.fmddlmyy.cn/text16.html http://www.fmddlmyy.cn/text17.html http://www.regexlab.com/zh/encoding.htm

좋은 웹페이지 즐겨찾기