iconv_open 中文man頁(yè)面
NAME
iconv_open - 分配一個(gè)字符集轉(zhuǎn)換的描述符
總覽 (SYNOPSIS)
#include <iconv.h> iconv_t iconv_open (const char* tocode, const char* fromcode);
描述 (DESCRIPTION)
iconv_open 函數(shù) 分配 一個(gè) 用于 把 fromcode 編碼的 字符串轉(zhuǎn)換成 tocode 編碼 的 轉(zhuǎn)換 描述符.
fromcode 和 tocode 所允許的值 以及 支持的 組合方式 都是 與系統(tǒng) 相關(guān)的. 對(duì)于 這個(gè) libiconv 庫(kù), 它 支持 下面 的 編碼, 也 支持 其所有 的 組合.
- 歐洲語(yǔ)言
- 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
- 閃米特語(yǔ)言
- 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
- 韓文
- EUC-KR, CP949, ISO-2022-KR, JOHAB
- Armenian
- ARMSCII-8
- Georgian
- Georgian-Academy, Georgian-PS
- 泰語(yǔ)
- TIS-620, CP874, MacThai
- 撈撾語(yǔ)
- MuleLao-1, CP1133
- 越南語(yǔ)
- VISCII, TCVN, CP1258
- 特定平臺(tái)
- HP-ROMAN8, NEXTSTEP
- Full Unicode
-
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 JAVA
- 用 uint16_t 或 uint32_t 表示的 Unicode
- (其 字節(jié)順序 和 對(duì)齊方式 與 具體 機(jī)器 有關(guān)) UCS-2-INTERNAL, UCS-4-INTERNAL
- 用 char 或 wchar_t 表示的 與 區(qū)域設(shè)置 相關(guān)的 編碼
- (其 字節(jié)順序 和 對(duì)齊方式 與 具體 機(jī)器 有關(guān), 其 語(yǔ)意 與操作系統(tǒng) 和 當(dāng)前 區(qū)域設(shè)置 中的 LC_CTYPE 有關(guān)) char, wchar_t
在 tocode 后面 加上 "//TRANSLIT" 表示, 當(dāng) 在目標(biāo) 字符集中 不能 表示 一個(gè) 字符 時(shí), 就用 同其 相似 的 一個(gè) 字符 來(lái) 代替.
其 返回的 轉(zhuǎn)換 描述符 可以 被 iconv 多次 使用. 只要 沒(méi)有 用 iconv_close 將其 釋放, 它 就是 有效的.
轉(zhuǎn)換 描述符 包含了 轉(zhuǎn)換的 狀態(tài). 在用 iconv_open 建立 一個(gè) 描述符時(shí) 狀態(tài)為 初始態(tài). iconv 會(huì) 改變 它的 狀態(tài). (這說(shuō)明 一個(gè) 描述符不能在 多線程中 同時(shí) 使用.) 可以 把 NULL 作為 inbuf 傳給 iconv 來(lái) 使其 回到 初始態(tài).
返回值 (RETURN VALUE)
iconv_open 函數(shù) 返回 一個(gè) 新的 轉(zhuǎn)換 描述符. 如果 發(fā)生 錯(cuò)誤 則設(shè)置 errno 變量 同時(shí) 返回 (iconv_t)(-1).
錯(cuò)誤 (ERRORS)
除了 一般的 錯(cuò)誤, 還可能 有 下面的 錯(cuò)誤:
- EINVAL
- 此系統(tǒng) 不支持 從 fromcode 到 tocode 的 轉(zhuǎn)換.
遵循 (CONFORMING TO)
UNIX98
參見(jiàn) (SEE ALSO)
iconv(3), iconv_close(3)
#p#
NAME
iconv_open - allocate descriptor for character set conversion
SYNOPSIS
#include <iconv.h> iconv_t iconv_open(const char *tocode, const char *fromcode);
DESCRIPTION
The iconv_open function allocates a conversion descriptor suitable for converting byte sequences from character encoding fromcode to character encoding tocode.
The values permitted for fromcode and tocode and the supported combinations are system dependent. For the GNU C library, the permitted values are listed by the iconv --list command, and all combinations of the listed values are supported.
The resulting conversion descriptor can be used with iconv any number of times. It remains valid until deallocated using iconv_close.
A conversion descriptor contains a conversion state. After creation using iconv_open, the state is in the initial state. Using iconv modifies the descriptor's conversion state. (This implies that a conversion descriptor can not be used in multiple threads simultaneously.) To bring the state back to the initial state, use iconv with NULL as inbuf argument.
RETURN VALUE
The iconv_open function returns a freshly allocated conversion descriptor. In case of error, it sets errno and returns (iconv_t)(-1).
ERRORS
The following error can occur, among others:
- EINVAL
- The conversion from fromcode to tocode is not supported by the implementation.
CONFORMING TO
UNIX98
SEE ALSO
iconv(3), iconv_close(3), iconv(1)