Using iconv to transform UTF-8 Chinese encoding into GB2312 character encoding error solution

time:11-02-17 forum:PHP tools and code
  Reloaded from the http://www.path8.net/tn/archives/2560

iconv () function can replace GB2312 to utf-8

[code]$text=iconv (.Quot; GB2312.quot;.Quot; UTF-8.quot; $text); The characters in the English name "," and so on, the conversion is broken. The characters after these characters can not be changed.

for this problem, you can use the following code to implement

[code]$text=iconv (.Quot; UTF-8.quot;.Quot; GBK.quot; $text); [/code]
you are not mistaken, so simple, not using GB2312, it is OK.

there is another way:

second parameters, plus //IGNORE, ignoring the error, as follows:
[code]iconv (.Quot; UTF-8.quot;.Quot; GB2312//IGNORE.quot; $data); NV ()

[code] iconv

(PHP 4.Gt; 4.0.5, PHP 5)
.Gt; [/code]

[code]string. The string is truncated.

can be solved at this time using the following methods:

[code]//author:zhxia
$str=iconv ('UTF-8', "" gb2312//TRANSLIT ", file_get_contents ($filepath)); [/code]
that is to add a red word part in second parameters, indicating that if the character matching the source code in the target code is not found. A similar character is selected for conversion.

can also be used here: //IGNORE, which means that characters that cannot be converted are ignored.

prev:The strftime () function converts month ... next:Ding Lei pig farm is about to enter the ...
post comment
Notice



approved   Ji'nan old shoemaker has made more t...   Ji'nan auxiliary police "storm" Engl...   Australian 16 year old girl, driving...   North drift Female Boxers earn "bloo...   The only teacher in island primary s...
rand   A brief discussion on comet Technolo...   Javascript/php implements comet (Aja...   Using Json to realize data exchange ...   PHP verification code landing check   Install.php simple production
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com