Display Big5 encoding from dBase on the web

帅比萌擦擦* 提交于 2020-01-05 09:12:18

问题


I have a dBase III file, the Chinese words inside is encoded in Big5. With the help of PHP ODBC, I can retreieve/ insert record to/ from the dBase file.

However, I couldn't diplay the chinese words (Big5) correctly.

When I use mb_detect_encodingfunction to detect those chinese words, it appears as "UTF-8". I guess the odbc dump the data in the form of "UTF-8" instead of it's original encoding (ASCII/ Big5).

I would like to ask, how can I display the words correctly? Thanks so much for your help. I have struggling for this problem for 2 days.


回答1:


You want to ensure the source and the display are both in UTF-8, and also everything that touches the data is set in UTF-8.

Start from what you are most certain about: Check the DB encoding. You can set a server wide encoding, a database encoding, a table encoding and a column encoding

Next, check the php that handles it The .php source file itself should be in UTF-8, the header and contentype charset etc should all be set to UTF-8.

If you sent the data to somewhere else like a javascript or other php pages for processing, you need to check them all as well. Be careful of any external library, or stream reader/writer, which encoding cannot be controlled by you. The connection you make with the DB may also alter the encoding.

Once you are sure the output is in UTF-8 you need to make sure the browser is displaying in UTF-8. You need to tell the browser what encoding this webpage is in, the browser read that in the header definition.

Good luck!



来源:https://stackoverflow.com/questions/13281899/display-big5-encoding-from-dbase-on-the-web

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!