mysql charset latin1 into utf-8 conversion issue

2019-09-07 00:10发布

问题:

My client's web app has large database which millions of records. All table's encoding is latin1.

When I fetch some text field which holds huge data and mail that string some strange haracter issue comes. Such when I recieve email spaces are converted into this character Â. It is not premissible to change the DB encoding. I tried the following PHP function but no outcome ;(

$msg = mb_convert_encoding($msg, "UTF-8", "latin1");

Please help

回答1:

I would check for the encoding php thinks it is

echo mb_detect_encoding($str);

And then do

iconv("detectedEncoding", "UTF-8", $str);

Or if iconv is not installed, check if your encoding was right in your solution. ;)



标签: utf-8 latin1