如何將亂碼的PHP網站(big5格式)轉換成能正常顯示的網頁(UTF-8格式)?

步驟 1

將所有要修改的*.php檔案下載回到本地

步驟 2

使用ConvertZ 8.02軟體批次將*.php檔案從big5轉換成utf-8格式

步驟 3

留意php檔案中的內容,把big5的地方改成utf-8。如下所示:

<?php echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?>
<?php
header("Content-Type:text/html; charset=utf-8");
header('Vary: Accept-Language');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/html; charset =UTF-8" />

步驟 4

由於原本的文字內容殘留著以big5格式所保存的字元,因此在轉換成utf-8格式的php檔案中,還是一樣存在亂碼的情形。這時候我們只要透過https://www.njstar.com/cms/cjk-code-to-unicode-conversion

貼入我們php檔案中的所有程式碼內容,按下Chinese Big5 to Unicode,即可進行轉換,再貼回原本的php檔案即可。

Written by

Machine Learning / Deep Learning / Python / Flutter cakeresume.com/yanwei-liu

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store