Converts a string from one specified encoding to another specified encoding. Note that the second parameter adds two suffixes, in addition to the encoding you can specify to convert to. Translit automatically converts characters that cannot be converted directly into one or more approximate characters,//ignore ignores characters that cannot be converted, and the default effect is to truncate from the first illegal character, for example:
Small traps using iconv transcoding in PHP
It is found that Iconv has an error converting the character "-" (characters after ASCII 150) to gb2312, and if there is no ignore parameter, all strings after that character cannot be saved. In any case, this "-" can not be converted successfully, unable to output. Another mb_convert_encoding does not have this bug.
In general, with Iconv, only use the Mb_convert_encoding function if you encounter an inability to determine what encoding the original encoding is, or if the Iconv conversion fails to display properly.
From_encoding is specified by character code name before conversion. It can be array or STRING-COMMA separated enumerated list. If It is not specified, the internal encoding would be used.
/* Auto detect encoding from JIS, Eucjp-win, Sjis-win, then convert str to Ucs-2le */ $str = mb_convert_encoding ($str, "Ucs-2le", "JIS, Eucjp-win, Sjis-win"); /* "Auto" is expanded to "ascii,jis,utf-8,euc-jp,sjis" */ $str = mb_convert_encoding ($str, "EUC-JP", "Auto");
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.