문제

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.

도움이 되었습니까?

해결책

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!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top