In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces which function is used from gbk to utf8 in php. It is very detailed and has certain reference value. Friends who are interested must finish reading it.
In php, you can convert gbk to utf8 through the iconv function, which converts a known character set file into another known character set file, such as "iconv (" GB2312 "," UTF-8 ", $data);".
This article operating environment: Windows7 system, PHP7.4 version, Dell G3 computer.
Function: PHP converts strings from GBK to UTF8 character set iconv
1. Introduction to iconv ()
The iconv function converts one known character set file into another known character set file. For example: convert from GB2312 to UTF-8.
The iconv function is built into php5, and the GB character set is turned on by default.
2. Iconv () error
Iconv will make an error when converting the character "-" to gb2312. The solution is to add "/ / IGNORE" after the encoding to be converted, that is, after the second argument of the iconv function. As follows:
Iconv ("UTF-8", "GB2312//IGNORE", $data)
Ignore means to ignore the conversion error, and without the ignore parameter, all strings following that character cannot be saved.
3. Iconv () example
Example 1:
Example 2:
If your PHP file is UTF-8 encoded, the following code will output correctly:
If your PHP file is GB, the following code works:
In the above case, the output of the program is:
% E6%88%91%E7%88%B1%E7%99%BE%E5%BA%A6
The above is all the contents of the article "which function to use from gbk to utf8 in php". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.