⑴ linux下編碼轉換問題,C語言實現,使用iconv函數族
1、iconv的含義是將一個抽象的符號的編碼進行轉換。
但是如果一個符號比如「個」,可能在BIG5的編碼中不存在(繁體字中不同)
GBK包含的是簡體字,BIG5包含的是繁體字,Unicode包含全部,
所以
GBK->Unicode,Big5-Unicode (總是OK)
Unicode->GBK (當裡面僅包含英文及簡體時OK)
Unicode->BIG5 (當裡面僅包含英文及繁體時OK)
GBK->Big5 (基本上不行,除非某些字沒有特別的簡體字)
GBK->Big5是漢字的簡繁轉換,不是編碼轉換,簡體字轉繁體字還有一個問題,一個簡體字可能是對應多個繁體字,這種很難轉換正確。繁體字轉換成簡體字相對難度低。
2、#include <iconv.h>
size_t iconv(iconv_t cd,
char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft);
函數原型, outbuf是一個 char **類型
在函數手冊中:
The iconv() function converts one multibyte character at a time, and for each character conversion it increments *inbuf and decrements
*inbytesleft by the number of converted input bytes, it increments *outbuf and decrements *outbytesleft by the number of converted
output bytes
⑵ linux之iconv命令
Linux中的iconv命令是一個專為文件編碼轉換而設計的工具。以下是關於iconv命令的詳細解答:
主要功能:
命令格式:
使用示例: