Get the App
SLTechnology News&Howtos  ›  Development  › 

How to convert gb2312 to utf8 in php

Shulou Source: shulou.com Published: 2022-06-03 10:39:43 11月15日 Update

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

Tags: Page content function more reference help good original interest guy buddy file article method environment computer knowledge example article system Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Docker Shulou Tech Info Microsoft vpn