search
HomeBackend DevelopmentPHP ProblemHow to solve the problem of php iconv error

Solution to php iconv error: 1. Use the [iconv("GB2312", "UTF-8", $text``);] method to replace gb2312 with "utf-8"; 2. Use [iconv("UTF-8", "GB2312//IGNORE"] method to solve it.

How to solve the problem of php iconv error

Recommended: "PHP Video Tutorial

icv error reporting problem in php

The iconv function library in php can complete the conversion between various character sets and is an indispensable basic function library in php programming ; But sometimes iconv will be less able to transcode some data for no reason. For example, an error will occur when converting the characters "— or Traditional Chinese" to gb2312.

Let's take a look at the usage of this function.

The simplest application is to replace gb2312 with utf-8:

`$text``=iconv(``"GB2312"``,``"UTF-8"``,``$text``);`

In the process of using $text=iconv("UTF-8","GB2312",$text), if When it comes to some special characters, such as: "— or Traditional Chinese", "." and other characters in English names, the conversion is interrupted. The text after these characters cannot be continued to be converted.

For This problem can be solved with the following code:

`$text``=iconv(``"UTF-8"``,``"GBK"``,``$text``);`

You read that right, it’s that simple, just don’t use gb2312 and write it as GBK.

There is another way, the first Two parameters, plus //IGNORE, ignore errors, as follows:

`iconv(``"UTF-8"``,``"GB2312//IGNORE"``,``$data``);`

There is no specific comparison between these two methods. I feel that the first method (GBK instead of gb2312) is better.

The above is the detailed content of How to solve the problem of php iconv error. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment