´ë¹®    
FindPage  |  TitleIndex  |  UserPreferences  |  [http]me2day  |  redpixel
RecentChanges
 


iconv

Contents

1 ¼Ò°³
2 ¼³Ä¡
3 GNU iconv ¸Þ´º¾ó ¹ø¿ª
3.1 iconv_open()
3.1.1 ¼³¸í
3.1.2 ¹Ýȯ°ª
3.1.3 errno
3.2 iconv()
3.2.1 ¼³¸í
3.2.2 ¹Ýȯ°ª
3.2.3 errno
3.3 iconv_close()
3.3.1 ¼³¸í
3.3.2 ¹Ýȯ°ª

1 ¼Ò°³ #

  • ȨÆäÀÌÁö : [http]http://www.gnu.org/software/libiconv/
  • °¢³ª¶óÀÇ ÄÚµåÆäÀÌÁö·Î ¹®ÀÚ¿­À» º¯È¯ÇØÁÖ´Â ¶óÀ̺귯¸®ÀÔ´Ï´Ù. ¿¹¸¦ µé¸é, ¿Ï¼ºÇü->Á¶ÇÕÇü, Á¶ÇÕÇü->UTF-8°ú °°Àº °ÍÀÌÁÒ. :)

2 ¼³Ä¡ #

  • mingw¿¡ ÀÌ¹Ì ºôµåµÈ ÀνºÅç°¡´ÉÇÑ ¹èÆ÷º»ÀÌ Á¸ÀçÇÕ´Ï´Ù. gettext¿Í »óÈ£ÂüÁ¶ ÀÇÁ¸¼ºÀÌ ÀÖÀ¸¹Ç·Î °°ÀÌ ¼³Ä¡ÇÏ´Â °ÍÀÌ ÁÁ½À´Ï´Ù.

3 GNU iconv ¸Þ´º¾ó ¹ø¿ª #


3.1 iconv_open() #

#include <iconv.h>

iconv_t iconv_open (const char* tocode, const char* fromcode);

3.1.1 ¼³¸í #

iconv_open ÇÔ¼ö´Â ¹®ÀÚ ÀÎÄÚµù fromcode¿¡¼­ ¹®ÀÚ ÀÎÄÚµù tocode ¹æ½ÄÀ¸·Î ¹®ÀÚ¿­À» º¯È¯ÇϱâÀ§ÇÑ º¯È¯±â ÇÚµéÀ» »ý¼ºÇÏ´Â ¿ªÇÒÀ» ÇÕ´Ï´Ù. fromcode¿Í tocode¿¡ ÁöÁ¤°¡´ÉÇÑ °ª°ú µÎ °ªÀÇ Á¶ÇÕÀº ½Ã½ºÅÛ¸¶´Ù ´Ù¸¨´Ï´Ù. libiconv ¶óÀ̺귯¸®¿¡¼­´Â ´ÙÀ½°ú °°Àº ÀÎÄÚµùÀÌ Áö¿øµÇ¸ç ¸ðµÎ »óÈ£Á¶ÇÕÀÌ °¡´ÉÇÕ´Ï´Ù.
Çѱ¹¾îEUC-KR, CP949, ISO-2022-KR, JOHAB
À¯·´ASCII, ISO-8859-{1,2,3,4,5,7,9,10,13,14,15,16}, KOI8-R, KOI8-U, KOI8-RU, CP{1250,1251,1252,1253,1254,1257}, CP{850,866}, Mac{Roman,CentralEurope,Iceland,Croatian,Romania}, Mac{Cyrillic,Ukraine,Greek,Turkish}, Macintosh
¼ÀÁ· °èÅëISO-8859-{6,8}, CP{1255,1256}, CP862, Mac{Hebrew,Arabic}
ÀϺ»¾îEUC-JP, SHIFT_JIS, CP932, ISO-2022-JP, ISO-2022-JP-2, ISO-2022-JP-1
Áß±¹¾îEUC-CN, HZ, GBK, GB18030, EUC-TW, BIG5, CP950, BIG5-HKSCS, ISO-2022-CN, ISO-2022-CN-EXT
¾Æ¸£¸Þ´Ï¾ÆARMSCII-8
±×·çÁö¾ÆGeorgian-Academy, Georgian-PS
ŸÁöŰ½ºÅºKOI8-T
ŸÀ̾îTIS-620, CP874, MacThai
¶ó¿À½ºMuleLao-1, CP1133
º£Æ®³²VISCII, TCVN, CP1258
ƯÁ¤ Ç÷¿Æû Àü¿ëHP-ROMAN8, NEXTSTEP
À¯´ÏÄÚµåUTF-8, UCS-2, UCS-2BE, UCS-2LE, UCS-4, UCS-4BE, UCS-4LE, UTF-16, UTF-16BE, UTF-16LE, UTF-32, UTF-32BE, UTF-32LE, UTF-7, C99, JAVA
uint16_t ¶Ç´Â uint32_t¿¡ ±âÃÊÇÑ À¯´ÏÄÚµå(½Ã½ºÅÛ ¿£µð¾È°ú Á¤·Ä¹æ½Ä¿¡ ÀÇÁ¸ÀûÀÓ)UCS-2-INTERNAL, UCS-4-INTERNAL
char ¶Ç´Â wchar_t¿¡ ±âÃÊÇÑ ·ÎÄÉÀÏ ÀÇÁ¸Àû(½Ã½ºÅÛ ¿£µð¾È°ú Á¤·Ä¹æ½Ä¿¡ ÀÇÁ¸ÀûÀÓ, LC_CTYPE ·ÎÄÉÀÏ facet°ú ¿î¿µÃ¼°è ¼³Á¤¿¡ µû¸§)char, wchar_t

--enable-extra-encodings ¿É¼ÇÀ» ÁÖ¾î ºôµåÇßÀ» °æ¿ì ´ÙÀ½°ú °°Àº Ãß°¡µÈ(Àß¾²ÀÌÁö ¾Ê´Â) ÀÎÄÚµù ¹æ½ÄÀ» »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.
À¯·´CP{437,737,775,852,853,855,857,858,860,861,863,865,869,1125}
¼À°èÅëCP864
ÀϺ»¾îEUC-JISX0213, Shift_JISX0213, ISO-2022-JP-3
Åõ¸£Å©¸à ¾ð¾îTDS565
ƯÁ¤ Ç÷¿Æû Àü¿ëRISCOS-LATIN1

  • ÀÎÄÚµù ¸íÀ» ""¿Í °°ÀÌ °ø¹éÀ¸·Î ÁöÁ¤Çϸé ÀÌ´Â "char"·Î ÁöÁ¤ÇÑ °Í°ú °°ÀÌ Ã³¸®µË´Ï´Ù : ÀÌ´Â ·ÎÄÉÀÏ ÀÇÁ¸ÀûÀÎ ¹®ÀÚ ÀÎÄÚµù ¹æ½ÄÀ» »ç¿ëÇÑ´Ù´Â ¶æÀÌ µË´Ï´Ù.
  • tocode¿¡ "//TRANSLIT"À» µ¡ºÙ¿© ÁöÁ¤ÇÏ¸é °íÃľ²±â ±â´ÉÀÌ È°¼ºÈ­µË´Ï´Ù. À̴ ƯÁ¤ ¹®ÀÚ°¡ °á°ú ¹®ÀÚÁýÇÕ¿¡ Á¸ÀçÇÏÁö ¾ÊÀ»°æ¿ì ºñ½ÁÇÏ°Ô º¸ÀÌ´Â ±ÛÀÚÁß Çϳª·Î ¾î¸²Àâ¾Æ ´ëüÇÑ´Ù´Â ÀǹÌÀÔ´Ï´Ù.
  • tocode¿¡ "//IGNORE"¸¦ µ¡ºÙ¿© ÁöÁ¤Çϸé, °á°ú ¹®ÀÚÁýÇÕ¿¡ Á¸ÀçÇÏÁö ¾Ê´Â ¹®ÀÚµéÀº ¾Æ¹«·± °æ°í¾øÀÌ °Ç³Ê¶Ù¾î 󸮵˴ϴÙ.
  • ¹ÝȯµÇ´Â º¯È¯±â ÇÚµéÀº iconv()ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ¸î¹øÀÌ°í ½ÇÇàÀÌ °¡´ÉÇÕ´Ï´Ù. ¸ðµç 󸮰¡ ³¡³ª¸é iconv_close()ÇÔ¼ö·Î ÀÌ ÇÚµéÀ» ´Ý¾ÆÁÖ¸é µË´Ï´Ù.
  • º¯È¯±â ÇÚµéÀº º¯È¯ »óŸ¦ ´ã°í ÀÖ½À´Ï´Ù. iconv_open() ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© »ý¼ºµÈ Á÷ÈÄ¿¡´Â, »óÅ´ Ãʱ⠻óÅ·ΠÁöÁ¤µË´Ï´Ù. iconv()ÇÔ¼ö¸¦ »ç¿ëÇϸé ÇÚµéÀÇ º¯È¯»óŸ¦ ¼öÁ¤ÇÏ°Ô µË´Ï´Ù. (ÀÌ´Â ´ÙÁß ¾²·¹µå ȯ°æ¿¡¼­ µ¿½Ã¿¡ ÇϳªÀÇ ÇÚµéÀ» °øÀ¯Çؼ­ »ç¿ëÇÒ ¼ö ¾ø´Ù´Â °ÍÀ» ÀǹÌÇÕ´Ï´Ù) »óŸ¦ ´Ù½Ã Ãʱâ»óÅ·ΠµÇµ¹¸®·Á¸é, iconv()¿¡ inbuf ¸Å°³º¯¼ö¿¡ NULLÀ» ÁöÁ¤ÇÏ¿© ½ÇÇàÇϼ¼¿ä.

3.1.2 ¹Ýȯ°ª #

iconv_open() ÇÔ¼ö´Â º¯È¯±â ÇÚµéÀ» ¹ÝȯÇÕ´Ï´Ù. ¿À·ù°¡ ¹ß»ýÇϸé errno¿¡ ÇØ´ç ¿À·ù°ªÀ» ¼³Á¤Çϰí (iconv_t)(-1)¸¦ ¹ÝȯÇÕ´Ï´Ù.

3.1.3 errno #

EINVALfromcode¿¡¼­ tocode·Î º¯È¯ÇÏ´Â ±â´ÉÀÌ ÇöÀç ±¸Çö¿¡¼­ Áö¿øµÇÁö ¾ÊÀ» °æ¿ì

3.2 iconv() #

#include <iconv.h>

size_t iconv (iconv_t cd, const char* * inbuf, size_t * inbytesleft, char* * outbuf, size_t * outbytesleft);

3.2.1 ¼³¸í #

  • ¸Å°³º¯¼ö cd´Â iconv_open()ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© »ý¼ºµÈ º¯È¯±â ÇÚµéÀ̾î¾ß¸¸ ÇÕ´Ï´Ù.
  • ±âº»ÀûÀÎ »ç¿ë¹ýÀº inbuf ¹× *inbuf ¸ðµÎ NULLÀÌ ¾Æ´Ò °æ¿ìÀÔ´Ï´Ù. In this case, the iconv function converts the multibyte sequence starting at *inbuf to a multibyte sequence starting at *outbuf. At most *inbytesleft bytes, starting at *inbuf, will be read. At most *outbytesleft bytes, starting at *outbuf, will be written.
  • iconv() ÇÔ¼ö´Â Çѹø¿¡ ÇϳªÀÇ ´ÙÁß¹ÙÀÌÆ® ¹®ÀÚ Çϳª¸¦ º¯È¯ÇÕ´Ï´Ù. ±×¸®°í °¢°¢ÀÇ ¹®ÀÚº¯È¯¶§¸¶´Ù º¯È¯µÈ ÀԷ¹®ÀÚ ¹ÙÀÌÆ®¼ö¸¸Å­ *inbuf¸¦ Áõ°¡½Ã۰í *inbytesleft¸¦ °¨¼Ò½ÃŰ°Ô µÇ¸ç, º¯È¯µÈ Ãâ·Â¹®ÀÚ ¹ÙÀÌÆ®¼ö¸¸Å­ *outbufÀ» Áõ°¡½Ã۰í *outbytesleft¸¦ °¨¼Ò½Ãŵ´Ï´Ù. ±×·±´ÙÀ½ cd º¯È¯±â Çڵ鳻ÀÇ º¯È¯ »óŸ¦ °»½ÅÇÕ´Ï´Ù. º¯È¯Àº ´ÙÀ½°ú °°Àº 4°¡Áö °æ¿ì¿¡ Á¤ÁöÇÏ°Ô µË´Ï´Ù.
    1. An invalid multibyte sequence is encountered in the input. In this case it sets errno to EILSEQ and returns (size_t)(-1). *inbuf is left pointing to the beginning of the invalid multibyte sequence.
    2. The input byte sequence has been entirely converted, i.e. *inbytesleft has gone down to 0. In this case iconv returns the number of non-reversible conversions performed during this call.
    3. An incomplete multibyte sequence is encountered in the input, and the input byte sequence terminates after it. In this case it sets errno to EINVAL and returns (size_t)(-1). *inbuf is left pointing to the beginning of the incomplete multibyte sequence.
    4. The output buffer has no more room for the next converted character. In this case it sets errno to E2BIG and returns (size_t)(-1).
  • A different case is when inbuf is NULL or *inbuf is NULL, but outbuf is not NULL and *outbuf is not NULL. In this case, the iconv function attempts to set cd's conversion state to the initial state and store a corresponding shift sequence at *outbuf. At most *outbytesleft bytes, starting at *outbuf, will be written. If the output buffer has no more room for this reset sequence, it sets errno to E2BIG and returns (size_t)(-1). Otherwise it increments *outbuf and decrements *outbytesleft by the number of bytes written.
  • inbuf°¡ NULL ¶Ç´Â *inbuf°¡ NULLÀ̸ç, outbuf°¡ NULL ¶Ç´Â *outbuf°¡ NULLÀÎ °æ¿ì¿¡´Â, iconv() ÇÔ¼ö´Â º¯È¯±â ÇÚµé cd³»ÀÇ º¯È¯ »óŸ¦ Ãʱ⠻óÅ·Πº¯°æÇÕ´Ï´Ù.

3.2.2 ¹Ýȯ°ª #

  • iconv() function returns the number of characters converted in a non-reversible way during this call; reversible conversions are not counted.
  • ¿À·ù°¡ ¹ß»ýÇϸé errno¿¡ ¿À·ùÄڵ带 ³Ö°í (iconv_t)(-1)¸¦ ¹ÝȯÇÕ´Ï´Ù.

3.2.3 errno #

E2BIG*outbuf¿¡ °ø°£ÀÌ ºÎÁ·ÇÕ´Ï´Ù
EILSEQºÎÁ¤È®ÇÑ ´ÙÁß¹ÙÀÌÆ® ¹®ÀÚ¿­ÀÌ ÀԷ°ªÀ¸·Î µé¾î¿Ô½À´Ï´Ù.
EINVAL¿Ï·áµÇÁö¾ÊÀº ´ÙÁß¹ÙÀÌÆ®¹®ÀÚ¿­ÀÌ ÀԷ°ªÀ¸·Î µé¾î¿Ô½À´Ï´Ù.

3.3 iconv_close() #

#include <iconv.h>

int iconv_close (iconv_t cd);

3.3.1 ¼³¸í #

iconv_open()¿¡¼­ »ý¼ºµÈ º¯È¯±â ÇÚµé cd¸¦ ÇØÁ¦ÇÕ´Ï´Ù.

3.3.2 ¹Ýȯ°ª #

  • ¼º°øÀûÀ¸·Î ½ÇÇàÀÌ ³¡³ª¸é iconv_close() ÇÔ¼ö´Â 0À» ¹ÝȯÇÕ´Ï´Ù.
  • ¿À·ù°¡ ¹ß»ýÇϸé errno¸¦ ¼³Á¤Çϰí -1À» ¹ÝȯÇÕ´Ï´Ù.


EditText | FindPage | DeletePage | LikePages

Powered by MoniWiki
xhtml1 | css2 | any browser | rss
Last modified 2004-02-26 12:56:33
Loading 0.3205 sec