PHP code conversion minus SIGN (connector) cannot convert problem technology
Maybe yes posted on 2015-01-23 16:03
Using PHP's Iconv or mb_convert_encoding functions for encoding conversions, such as converting gb2312 to utf-8 encoding, does not work when certain special characters (minus, connector) appear, and may become a question mark "?". or "C". Try a variety of methods, still can't solve this problem well. The following code, after declaring the//ignore, encounters the connection symbol "-" will still become the symbol "?".
According to the PHP official website manual to provide the solution to try, still can't solve the problem, do not know is not my local PHP version of the problem.
Workaround One:
Please note that iconv (' UTF-8 ', ' ascii//translit ', ...) doesn ' t work properly when locale category Lc_ctype are set to C or Posix. You must choose another locales otherwise all non-ascii characters would be replaced with question marks. This was at least true with GLIBC 2.5.
Example:
Translation
Note that Iconv does not work correctly when the locale category Lc_ctype category is set to C or POSIX. You must choose another language, otherwise all non-ASCLL encodings will be replaced with a question mark "?". This problem is true under GLIBC 2.5.
Examples are as follows:
!--? Phpsetlocale (lc_ctype, ' POSIX '); Echo iconv (' UTF-8 ', ' ascii//translit ', "?lu?ou?ký k?? \ n ");//? lu?ou?k? K?? SetLocale (lc_ctype, ' Cs_cz '); Echo iconv (' UTF-8 ', ' ascii//translit ', '?lu?ou?ký k?? \ n ")//Zlutoucky kun Workaround two:
that would strip invalid characters from UTF-8 strings (so the can insert it into a database, etc.). Instead of "None" you can also use the value if you want it to insert spaces in place of the invalid characters.
Read (75) reviews (0) View comments