mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-24 18:50:12 +01:00
src: fix gb2312 -> utf8 iconv conversion issue
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
1c27ead3af
commit
25aeff66ba
@ -323,6 +323,15 @@ int utf8_encode(char *inbuf, int inbuflen, char *outbuf, int outbuflen, char *en
|
||||
|
||||
memset(outbuf, 0, outbuflen);
|
||||
|
||||
// Iconv sometimes produces an invalid utf8 sequence for gb2312.
|
||||
// The fix is to use cp936, instead of gb2312 encoding.
|
||||
//
|
||||
// If there will be more similar exceptions, then we have to use
|
||||
// a more efficient lookup method
|
||||
|
||||
if(strcasecmp(encoding, "gb2312") == 0)
|
||||
cd = iconv_open("utf-8", "cp936");
|
||||
else
|
||||
cd = iconv_open("utf-8", encoding);
|
||||
|
||||
if(cd != (iconv_t)-1){
|
||||
@ -339,4 +348,3 @@ int utf8_encode(char *inbuf, int inbuflen, char *outbuf, int outbuflen, char *en
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user