Home > Backend Development > PHP Tutorial > iconv transcoding failed for UTF8 encoded page in php_PHP tutorial

iconv transcoding failed for UTF8 encoded page in php_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:56:48
Original
1098 people have browsed it

This article introduces the content loss and solutions when using iconv to encounter characters that cannot be transcoded when storing GBK data in a UTF8 encoded page. Students who have encountered such problems can refer to it.

About iconv interrupting and losing content when encountering characters that cannot be transcoded

The code is as follows
 代码如下 复制代码

$c = ‘测试•字符传换•五一快乐!’;

echo iconv(‘utf-8′, ‘gbk’,$c);

Copy code

$c = ‘Test•Character transfer•Happy May Day! ’;

echo iconv(‘utf-8′, ‘gbk’,$c);

Only output: test
 代码如下 复制代码

$c = ‘测试•字符传换•五一快乐!’;

echo iconv(‘utf-8′, ‘gbk//IGNORE’,$c);

The last one will be lost.

Solution:

Add //IGNORE
The code is as follows
Copy code

$c = ‘Test•Character transfer•Happy May Day! ’;

Input and output: Test character transfer Happy May Day! ignore means to ignore errors during conversion. Without the ignore parameter, all strings following this character cannot be saved. This way you can do the same
http://www.bkjia.com/PHPjc/632140.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632140.htmlTechArticleThis article introduces the interrupt content when using iconv to store GBK data in UTF8 encoded pages when encountering characters that cannot be transcoded. The loss and solutions are available for reference by students who have encountered such problems. About iconv...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template