用于中文文本的php utf-8编码

I am doing migration to generate SQL from one DB to another.

I am trying to get the output enter image description here

But when I did a mb_convert_encoding("Mr.Wang (王老板)", 'UTF-8', 'Windows-1252')

I have the output as enter image description here

I have those two extra "box". Any idea what am I doing wrong?

phpMyAdmin is able to export my old database containing chinese text in correct format, how do it do that in script?

*updated the images to better show my view

Have you tried setting the header in the script to UTF8? What I normally use is the following:

header('Content-Type: text/html; charset=utf-8');

That has worked for me so far for German characters & some Arabic & Japanese etc.

I found that I actually need to

mysql_query("SET NAMES 'utf8'");

before my select statement. And I do not need to run mb_convert_encoding("Mr.Wang (王老板)", 'UTF-8', 'Windows-1252') at all.

Now if I write my insert sql I got the correct text i wanted.