1 頁 (共 1 頁)

[問題]phpbb2.0.21文章標題UNICODE碼問題

發表於 : 2006-08-06 14:48
阿治
[環境]
●架設主機作業系統:Windows2000Server
●架站程式:IIS
●上網方式:學術網
●您安裝的程式:IIS + php + MySql
●您的 phpBB2 版本:phpBB2.0.21


[問題描述]
------------------------------------------------------------------------------
整個PHPBB站顯示中文均正常, 但在文章標題的地方確是以UNICODE碼顥示, 如文字:
---------------------------------------

代碼: 選擇全部

測test --變成-->& #28204;test
---------------------------------------
p.s上面例子實際上&和#之間是沒有空格的
但如果是打在發文內文則顥示正常
我直接看資料庫後發現, 在phpbb_posts_text資料表中的post_subject欄位,原本應該編碼成"& #28204;test"的文字,
都變成測test
多了一個amp; 我想是這個原因造成文章標題都無法顥示中文字, 但不知如何解決
不知有人有相同狀況? 該如何解決 :cry:

發表於 : 2006-08-07 02:17
心靈捕手
我猜想:
您的論壇語系編碼是 'big5'

建議您:
1. 貼出論壇網址
2. 提供測試用帳號與密碼

發表於 : 2006-08-07 12:23
chiouss
昨天翻翻 phpBB 的 FAQ.html 才發現內容好像有增加了,裡面第 12 項有寫到這種問題,不知道有沒有用?
12. I am seeing &#nnnn; sequences output instead of what I typed!

To enable compliance with HTML and XHTML specifications as well as enabling browsers to automatically support a users selected language we enable a charset tag to be output to the browser. This identifies the primary character set the user has selected, eg. iso-8859-1 for Western European languages (English, German, French, etc.), windows-1251 for Cyrillic alphabets (Russian, Bulgarian, etc.) and so on. The downside to doing this is that most modern browsers (such as Internet Explorer) convert any character not present in that character set into what are termed Numerical Character References or NCR's. These take the form of &#nnnn; where nnnn is the hexadecimal number of that characters UNICODE reference.

Unfortunately PHP (which effectively supports only iso-8859-1 at this time) does not appear to attempt to process this data back into normal characters. Therefore phpBB treats them as text the user has entered and wishes to see. phpBB enables this by turning the & into &. This results in the characters appearing as they do. Although we could ignore &#nnnn; (there are pro's and of course con's to doing so) at present we don't.

If you are finding this to be problem the solution is to remove the

代碼: 選擇全部

charset={S_CONTENT_ENCODING}
text from all the _header.tpl template files in all templates. The downside to this is a users browser will not automatically switch its charset to that selected by the user (however this is unlikely to be a big problem since users typically run their browser by default in the language they wish to use). Alternatively you can modify the $lang['ENCODING'] entry in the appropriate language file. Until PHP (and all browsers!) trully support UNICODE these problems will persist across all boards.