首先是討論區本身 UTF-8 的作法,這邊已經有很多前輩分享了作法,我也是採用一樣的方法,也就是討論區程式不做任何更動,而是去更動 language 目錄下面的 *.php 檔案,利用 ConvertZ 或 EmEditor,轉換為 UTF-8 格式,並且注意不要有 BOM 特徵。
再把 lang_main.php 中,一開頭改成 $lang['ENCODING'] = 'UTF-8'; 如此一來整個討論區就已經 UTF-8 化,存在資料庫中的也都是 UTF-8 格式的文字。
但對於信件亂碼的問題,我的解決方法則在這邊沒找到,如果已經有人提過就當我多嘴囉!分享如下:
1. 將 language/XXX/email/ 下的 *.tpl 檔,全部轉換成 UTF-8,並且,每一個檔案都要打開來編輯,把頭一行或頭二行寫著 Charset 的地方均改成 Charset: UTF-8。
2. 我以 2.0.17 版為準,修改程式 includes/emailer.php,找 190 行附近,寫著:
代碼: 選擇全部
$this->extra_headers = (($this->reply_to != '') ? "Reply-to: $this->reply_to
" : '') . (($this->from != '') ? "From: $this->from
" : "From: " . $board_config['board_email'] . "
") . "Return-Path: " . $board_config['board_email'] . "
Message-ID: <" . md5(uniqid(time())) . "@" . $board_config['server_name'] . ">
MIME-Version: 1.0
Content-type: text/plain; charset=" . $this->encoding . "
Content-transfer-encoding: 8bit
Date: " . date('r', time()) . "
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: PHP
X-MimeOLE: Produced By phpBB2
" . $this->extra_headers . (($cc != '') ? "Cc: $cc
" : '') . (($bcc != '') ? "Bcc: $bcc
" : '');
代碼: 選擇全部
$this->extra_headers=(($this->reply_to != '') ? "Reply-to: $this->reply_to
" : '') . (($this->from != '') ? "From: $this->from
" : "From: " . $board_config['board_email'] . "
") . "Return-Path: " . $board_config['board_email'] . "
Message-ID: <" . md5(uniqid(time())) . "@" . $board_config['server_name'] . ">
MIME-Version: 1.0
Content-type: text/plain; charset=" . $this->encoding . "
Date: " . date('r', time()) . "
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: PHP
X-MimeOLE: Produced By phpBB2
" . $this->extra_headers . (($cc != '') ? "Cc: $cc
" : '') . (($bcc != '') ? "Bcc: $bcc
" : '');
3. 修改完成,這樣一來寄出來的信件不論是標題還是內文,均是 UTF-8 格式。我收信軟體是 Outlook 2003,可以正確顯示沒有問題。
我自己在公司中架設的討論區就是 UTF-8,操作語系包含簡繁體中文、英文、日文、韓文,不論是畫面還是信件,均正常,由員工自行決定要看什麼語系的介面。