我用UTF8转GBK,用的iconv函数
void TransContent(const char *pFromCode, const char *pToCode, const char *pInBuf, size_t iInLen, char *pOutBuf, size_t iOutLen){    char* sResult = NULL;    //打开字符集转换
    iconv_t hIconv = iconv_open(pToCode, pFromCode);    if (!hIconv) return;    //开始转换
    size_t iRet = iconv(hIconv, (char **)(&pInBuf), &iInLen, &pOutBuf, &iOutLen);    //关闭字符集转换
    iconv_close(hIconv);
}
TransContent("UTF-8", "GBK//IGNORE", "碶", strlen("碶"), pOutputBuf, sizeof(pOutputBuf));
TransContent("UTF-8", "GBK//IGNORE", "㯖", strlen("㯖"), pOutputBuf, sizeof(pOutputBuf));碶这个字会被转换为未知字符,㯖这个字会被ignore掉,变成""。
GBK字符集里面这两个字都没有,
为什么一个会被错误转码,一个会被ignore?
ignore是因为识别不了,被转换为"",错误编码是因为系统以为能识别,结果转码错误了。
所以这俩字有啥区别?
 猛跑小猪
猛跑小猪 
					明月笑刀无情
 随时随地看视频慕课网APP
随时随地看视频慕课网APP