Is there any difference in the coding of the two words?

I use UTF8 to transfer the iconv function for GBK,

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));
The word "ignore" will be converted to an unknown character, and the word "" will be dropped to "". There are none of these two words in the
GBK character set.
Why is one transcoded incorrectly and the other ignore??

ignore is converted to "" because it cannot be recognized, and the error code is because the system thinks it can be recognized, so the transcoding is wrong.

so what"s the difference between these two words?

https://blog.csdn.net/wang123.

I read this article saying that the word "this word is actually"\

then how to transcode in such a situation?

Oct.29,2021

try Unicode Encoding

GBK itself has a lot of Chinese characters that can not be covered, which is determined by coding. When I was doing XML parsing, I came across some obscure words like this, which were later converted into GB2312.

the above is an incorrect answer and has been corrected in the comments.


I tried

with two character conversion libraries of PHP.
iconv managers
UTF-8
[len] 1

[0xE7 0xA2 0xB6]
GBK
/ / misreported
iconv customers
UTF-8
[stories]
[0xE3 0xAF 0x96]
[len] 0
GBK
/ / No output
mbstring managers
UTF-8
[len] 1
[code >] [0xE7 0xA2 0xB6] GBK
[len] 2
[courses] []
[0xE7 0xA2] [0xB6]
mbstring managers
UTF-8
[len] 1
[code >] [0xE3 0xAF 0x96] GBK
[len] 2
[]
[0xE3 0xAF] [0x96]

mbstring two words are converted
iconv one is empty, the other is wrong

synthesizing your code output, it should be a problem with the implementation of iconv, so mbstring can be transferred, isn't it?
I have seen related articles in my impression, and both of them should look up the table

.
Menu