PHP character encoding conversion problem
Jul 25, 2016 am 08:53 AM
For example: the web page uses gbk encoding, the string uses utf-8 encoding, convert the characters to Web page display encoding.
Summary: It is recommended to use the mb_convert_encoding function, which has no iconv conversion character error problem. Convert the encoding of the string to UTF-8. If you know the encoding of the original string, you can use the iconv function that everyone is familiar with. But now you don’t know the encoding of the original string. It may be GBK, or it may be UTF-8, so you cannot use this method. It would be great if you could get the string encoding type, or have an encoding conversion function that automatically recognizes the original string encoding. It turns out that the mb_convert_encoding function is the function that can automatically identify the original string encoding. However, during use, it was found that some Chinese characters in GBK were converted into garbled characters. Later I found the is_utf8 function in the PHP manual, and then combined with the iconv function, the problem was solved. Encoding conversion function used:
|

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel

Build a React App With a Laravel Back End: Part 2, React

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon

Announcement of 2025 PHP Situation Survey
