Home >Backend Development >PHP Tutorial >PHP iconv function usage examples and precautions
Notes on using iconv function in php When using iconv() to convert a character that is not supported by the output character encoding, such as iconv('UTF-8', 'GB2312', '囧'), you will encounter this error message: Notice: iconv() [function.iconv]: Detected an illegal character in input string ... Because GB2312 represents Simplified Chinese and does not support more complex Chinese characters such as "囧" and some special characters, this will of course result in an error. There are two solutions: 1. Expand the range of output character encoding, such as iconv('UTF-8', 'GBK', '囧'), which can be output correctly because GBK supports a wider range of characters; 2. Add "//IGNORE" after the output character encoding string, such as iconv('UTF-8', 'GB2312//IGNORE', '囧'), which ignores characters that cannot be converted and avoids errors. But it cannot be output correctly (that is, blank is not output). |