Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to convert gb2312 to utf8 in php

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces how to convert gb2312 to utf8 in php, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Php gb2312 to utf8 conversion methods: 1, open the corresponding PHP file; 2, check the original code; 3, by using preg_replace and iconv functions to convert gb2312 pages to utf8 pages.

This article operating environment: Windows7 system, PHP7.1, Dell G3 computer.

How to convert php gb2312 to utf8?

Convert PHP gb2312 pages to utf8 pages

Two functions, preg_replace and iconv, are used

$html = preg_replace ('/ charset=gb2312/', 'charset=UTF8', $html); / / $enc = mb_detect_encoding ($html); $html = iconv (' gbk', 'utf-8', $html)

Https://php.net/manual/en/function.iconv.php

Https://www.php.net/manual/en/function.preg-replace.php

Refer to the example on the official website of php

Example # 2 Using indexed arrays with preg_replace () Example # 1 iconv () example

* testurl.php

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report