iconv Detected an illegal character in input string

5.6k views Asked by At

I don't know chinese language. But I faced problem using these codes:

iconv('UTF-8', 'GB2312', '在世界自由软件日给中国自由软件爱好者的视');

runs ok with no problem.

and this one:

iconv('UTF-8', 'GB2312', '冠軍集團安心居台北旗艦總店開幕酒會暨記者會');

which causes error:

Message: iconv(): Detected an illegal character in input string

Both are chinese but what's the difference?

1

There are 1 answers

0
Fwolf On

Your second string is not GB2312 encode, it's BIG5 encoding.

So, you should use 'GBK' as 'from encoding' instead, which covers GB2312 and BIG5.