뜬금없는 이야기지만, 일단 iconv는 libc 를 이용한다.
그런데 이 넘은 실제로 /usr/lib/gconv/*.so 파일들을 사용한다.
아무튼, 이 넘들이 없으면 에러는 안나지만 변환이 안된다.
(임베디드에서 iconv 쓰는데 변환이 안되서 찾은 문제)
# ll -h /usr/lib/gconv/ total 7.2M
-rwxr-xr-x 1 root root 22K Oct 9 2006 ANSI_X3.110.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ARMSCII-8.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ASMO_449.so
-rwxr-xr-x 1 root root 218K Oct 9 2006 BIG5HKSCS.so
-rwxr-xr-x 1 root root 82K Oct 9 2006 BIG5.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 CP10007.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 CP1125.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 CP1250.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 CP1251.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 CP1252.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 CP1253.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 CP1254.so
-rwxr-xr-x 1 root root 14K Oct 9 2006 CP1255.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 CP1256.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 CP1257.so
-rwxr-xr-x 1 root root 14K Oct 9 2006 CP1258.so
-rwxr-xr-x 1 root root 9.5K Oct 9 2006 CP737.so
-rwxr-xr-x 1 root root 9.6K Oct 9 2006 CP775.so
-rwxr-xr-x 1 root root 94K Oct 9 2006 CP932.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 CSN_369103.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 CWI.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 DEC-MCS.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 EBCDIC-AT-DE-A.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 EBCDIC-AT-DE.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 EBCDIC-CA-FR.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 EBCDIC-DK-NO-A.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 EBCDIC-DK-NO.so
-rwxr-xr-x 1 root root 18K Oct 9 2006 EBCDIC-ES-A.so
-rwxr-xr-x 1 root root 18K Oct 9 2006 EBCDIC-ES.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 EBCDIC-ES-S.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 EBCDIC-FI-SE-A.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 EBCDIC-FI-SE.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 EBCDIC-FR.so
-rwxr-xr-x 1 root root 18K Oct 9 2006 EBCDIC-IS-FRISS.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 EBCDIC-IT.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 EBCDIC-PT.so
-rwxr-xr-x 1 root root 18K Oct 9 2006 EBCDIC-UK.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 EBCDIC-US.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ECMA-CYRILLIC.so
-rwxr-xr-x 1 root root 14K Oct 9 2006 EUC-CN.so
-rwxr-xr-x 1 root root 14K Oct 9 2006 EUC-JISX0213.so
-rwxr-xr-x 1 root root 82K Oct 9 2006 EUC-JP-MS.so
-rwxr-xr-x 1 root root 14K Oct 9 2006 EUC-JP.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 EUC-KR.so
-rwxr-xr-x 1 root root 22K Oct 9 2006 EUC-TW.so
-rwxr-xr-x 1 root root 178K Oct 9 2006 GB18030.so
-rwxr-xr-x 1 root root 54K Oct 9 2006 GBBIG5.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 GBGBK.so
-rwxr-xr-x 1 root root 110K Oct 9 2006 GBK.so
-rw-r--r-- 1 root root 54K Oct 8 2006 gconv-modules
-rw-r--r-- 1 root root 25K Feb 16 13:23 gconv-modules.cache
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 GEORGIAN-ACADEMY.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 GEORGIAN-PS.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 GOST_19768-74.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 GREEK7-OLD.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 GREEK7.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 GREEK-CCITT.so
-rwxr-xr-x 1 root root 18K Oct 9 2006 HP-ROMAN8.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM037.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM038.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1004.so
-rwxr-xr-x 1 root root 5.4K Oct 9 2006 IBM1008_420.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1008.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1025.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1026.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1046.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1047.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1097.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1112.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1122.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1123.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1124.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1129.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1130.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1132.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1133.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1137.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1140.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1141.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1142.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1143.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1144.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1145.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1146.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1147.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1148.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1149.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1153.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1154.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1155.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1156.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1157.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1158.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1160.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1161.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1162.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1163.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1164.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1166.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM1167.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM12712.so
-rwxr-xr-x 1 root root 146K Oct 9 2006 IBM1364.so
-rwxr-xr-x 1 root root 122K Oct 9 2006 IBM1371.so
-rwxr-xr-x 1 root root 166K Oct 9 2006 IBM1388.so
-rwxr-xr-x 1 root root 222K Oct 9 2006 IBM1390.so
-rwxr-xr-x 1 root root 222K Oct 9 2006 IBM1399.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM16804.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM256.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM273.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM274.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM275.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM277.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM278.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM280.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM281.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM284.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM285.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM290.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM297.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM420.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM423.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM424.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM437.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM4517.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM4899.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM4909.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM4971.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM500.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM5347.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM803.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM850.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM851.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM852.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM855.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM856.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM857.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM860.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM861.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM862.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM863.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM864.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM865.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM866NAV.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM866.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM868.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM869.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM870.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM871.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM874.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM875.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM880.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM891.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM901.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM902.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM9030.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM903.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM904.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM905.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM9066.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM918.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM921.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM922.so
-rwxr-xr-x 1 root root 94K Oct 9 2006 IBM930.so
-rwxr-xr-x 1 root root 66K Oct 9 2006 IBM932.so
-rwxr-xr-x 1 root root 114K Oct 9 2006 IBM933.so
-rwxr-xr-x 1 root root 82K Oct 9 2006 IBM935.so
-rwxr-xr-x 1 root root 110K Oct 9 2006 IBM937.so
-rwxr-xr-x 1 root root 94K Oct 9 2006 IBM939.so
-rwxr-xr-x 1 root root 66K Oct 9 2006 IBM943.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IBM9448.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 IEC_P27-1.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 INIS-8.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 INIS-CYRILLIC.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 INIS.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISIRI-3342.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO_10367-BOX.so
-rwxr-xr-x 1 root root 5.4K Oct 9 2006 ISO_11548-1.so
-rwxr-xr-x 1 root root 38K Oct 9 2006 ISO-2022-CN-EXT.so
-rwxr-xr-x 1 root root 26K Oct 9 2006 ISO-2022-CN.so
-rwxr-xr-x 1 root root 22K Oct 9 2006 ISO-2022-JP-3.so
-rwxr-xr-x 1 root root 34K Oct 9 2006 ISO-2022-JP.so
-rwxr-xr-x 1 root root 14K Oct 9 2006 ISO-2022-KR.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO_2033.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO_5427-EXT.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO_5427.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO_5428.so
-rwxr-xr-x 1 root root 22K Oct 9 2006 ISO646.so
-rwxr-xr-x 1 root root 18K Oct 9 2006 ISO_6937-2.so
-rwxr-xr-x 1 root root 18K Oct 9 2006 ISO_6937.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO8859-10.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO8859-11.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO8859-13.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO8859-14.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO8859-15.so
-rwxr-xr-x 1 root root 18K Oct 9 2006 ISO8859-16.so
-rwxr-xr-x 1 root root 5.4K Oct 9 2006 ISO8859-1.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO8859-2.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO8859-3.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO8859-4.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO8859-5.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO8859-6.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO8859-7.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO8859-8.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO8859-9.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO-IR-197.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 ISO-IR-209.so
-rwxr-xr-x 1 root root 14K Oct 9 2006 JOHAB.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 KOI8-R.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 KOI-8.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 KOI8-T.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 KOI8-U.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 LATIN-GREEK-1.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 LATIN-GREEK.so
-rwxr-xr-x 1 root root 454K Oct 9 2006 libCNS.so
-rwxr-xr-x 1 root root 66K Oct 9 2006 libGB.so
-rwxr-xr-x 1 root root 58K Oct 9 2006 libISOIR165.so
-rwxr-xr-x 1 root root 98K Oct 9 2006 libJIS.so
-rwxr-xr-x 1 root root 118K Oct 9 2006 libJISX0213.so
-rwxr-xr-x 1 root root 46K Oct 9 2006 libKSC.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 MACINTOSH.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 MAC-IS.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 MAC-SAMI.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 MAC-UK.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 MIK.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 NATS-DANO.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 NATS-SEFI.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 PT154.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 RK1048.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 SAMI-WS2.so
-rwxr-xr-x 1 root root 14K Oct 9 2006 SHIFT_JISX0213.so
-rwxr-xr-x 1 root root 90K Oct 9 2006 SJIS.so
-rwxr-xr-x 1 root root 18K Oct 9 2006 T.61.so
-rwxr-xr-x 1 root root 14K Oct 9 2006 TCVN5712-1.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 TIS-620.so
-rwxr-xr-x 1 root root 18K Oct 9 2006 TSCII.so
-rwxr-xr-x 1 root root 70K Oct 9 2006 UHC.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 UNICODE.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 UTF-16.so
-rwxr-xr-x 1 root root 9.4K Oct 9 2006 UTF-32.so
-rwxr-xr-x 1 root root 18K Oct 9 2006 UTF-7.so
-rwxr-xr-x 1 root root 18K Oct 9 2006 VISCII.so
strace를 해보니
gconv-module은 /usr/lib/gconv-modules에서 잘 open 했는데 EUC-KR.so 를 open 한 후
libc.so.6와 ld-linux.so.2를 찾네요, 저는 shared library를 안쓰고 있는데 ㅠㅠ 그래서 위 두 파일을
ramdisk/usr/lib 에 복사해 넣은 후 TARGET에서 다시 iconv sample 프로그램을 돌려보니 이제는 정상
동작 합니다.
음.. 그래서 일단은 libc*로 파일들을 검색해보니 "libc.so" 가 없다.
so 라길레 파일 용량을 보니 저렴한 238Byte. 그래서 cat으로 해보니 텍스트 파일이다.
>>> x86 리눅스의 libc.so 내용
# cat /usr/lib/libc.so
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-i386)
GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux.so.2 ) )
>>> sh4 리눅스의 libc.so 내용
]# cat usr/lib/libc.so
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-sh-linux)
GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( /lib/ld-linux.so.2 ) )
수동으로 crt 코드와 libc를 링크시켜 줍니다. 여기까지 해서 동작을 잘 해야 하는데, 컴파일/링킹 워닝이나 에러가 안나지만
프로그램이 동작하지 않습니다.
$ readelf -l test
...
INTERP 0x000114 0x08048114 0x08048114 0x00013 0x00013 R 0x1
[Requesting program interpreter: /usr/lib/libc.so.1]
...
dynamic
linker를 시스템 기본값인 /usr/lib/libc.so.1로 지정하는데, 문제는 시스템에는 해당 파일이 없습니다--;
마찬가지 방법으로 /bin/ls의 INTERP 섹션을 읽어보니까 INTERP는 /lib/ld-linux.so.2로 되어 있네요.
위에서 /usr/lib/libc.so.1 은 없고 /usr/lib/libc.so는 있는데, 이 파일의 내용은 다음과 같습니다.
$ cat /usr/lib/libc.so
/* GNU ld script
Use the
shared library, but some functions are only in
the static library,
so try that secondarily. */
OUTPUT_FORMAT(elf32-i386)
GROUP (
/lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux.so.2
) )
그리고 iconv() 함수는
문자열 변수들은 2중 포인터로 넘겨주고(왜?) inbytesleft는 strlen(*inbuf) 의 값을 outbytesleft는 strlen(*outbuf) 의 값을 넣어주면된다.
물론 변환에 따라서, 길이가 가변적으로 달라질수 있기 때문에 주의해야 한다.
만약, 변환중 메모리가 넘치게 되면 EILSEQ 에러가 발생하게 되며, (물론 넘치기 전에 데이터는 빼낼수 있다.)
변수의 포인터가 2중 포인터가 아니면 "__gconv: Assertion `outbuf != ((void *)0) && *outbuf != ((void *)0)' failed."
이런 에러를 만나게 될 것이다.
iconv는 utf 나 iso8859 등, 여러가지 방법으로
문자열 코딩을 변환해주는 역활을 하는 함수/유틸리티이다.
$ man -k iconv
iconv (1) - Convert encoding of given files from one encoding to another
iconv (1p) - codeset conversion
iconv (3) - perform character set conversion
iconv (3p) - codeset conversion function
iconv.h [iconv] (0p) - codeset conversion facility
iconv_close (3) - deallocate descriptor for character set conversion
iconv_close (3p) - codeset conversion deallocation function
iconv_open (3) - allocate descriptor for character set conversion
iconv_open (3p) - codeset conversion allocation function
아무튼, iconv는 함수(3/3p) 이자 유틸리티(1) 인데
함수의 경우 iconv_open() - iconv() - iconv_close() 를 이용하여 사용한다.
$ iconv --list
The following list contain all the coded character sets known. This
does
not necessarily mean that all combinations of these names can be used
for
the FROM and TO command line parameters. One coded character set can be
listed with several different names (aliases).