These two functions have their own characteristics,
1, iconv speed, natural preference, but he has a disadvantage, if you encounter the character can not be converted, it is truncated from there. This causes the content in the transcoding to be truncated for no reason.
2, the mb_convert_encoding function is less efficient, but he encounters the content that cannot be converted is not truncated, which preserves the integrity of the content to a great extent. But I found that if there were spaces in the content, the converted content would be. symbols, or not perfect enough.
How do I combine these two functions to transcode characters?
My train of thought is this:
It is preferable to use the ICONV function because it is efficient and built-in function. Discuz transcoding function is also preferred to use this function, but his transcoding is not complete, it is necessary to arrange mb_convert_encoding to clean up the mess, the question came, how to judge his transcoding is not complete?
Reply to discussion (solution)
Although the mb_convert_encoding function needs to load the php_mbstring extension
But it's not a built-in function to load.
For unrecognized characters, the ICONV provides two switches for you to choose from, and not to blindly truncate
Translit to replace with similar characters
IGNORE Discard and Continue
Although the mb_convert_encoding function needs to load the php_mbstring extension
But it's not a built-in function to load.
For unrecognized characters, the ICONV provides two switches for you to choose from, and not to blindly truncate
Translit to replace with similar characters
IGNORE Discard and Continue
As if I had added the Ignore function, but some of the content transcoding is still not ideal.
In other words, sometimes with iconv line, mb_convert_encoding not, mb_convert_encoding line, iconv and not
Although the mb_convert_encoding function needs to load the php_mbstring extension
But it's not a built-in function to load.
For unrecognized characters, the ICONV provides two switches for you to choose from, and not to blindly truncate
Translit to replace with similar characters
IGNORE Discard and Continue
Experiment, the ignore may be able to go around the past (before the encounter can not be spared), but the conversion of certain characters, the character is lost.
Like, "?" When the symbol was converted into gb2312, Iconv did not convert, but mb_convert_encoding converted. So the two have advantages and disadvantages, now just how to compare the perfect combination to use.