如何将Windows-1252字符转换为php中的值?

dbc*_*bcn 5 php utf-8 windows-1252

我们有几个包含Windows-1252字符的数据库字段:

an example pain— if you’re
Run Code Online (Sandbox Code Playgroud)

这些值映射到此列表中的所需值:

http://www.i18nqa.com/debug/utf8-debug.html

我尝试了各种htmlentites,mb_detect_encoding,uft8_decode等的排列,但还没有能够将这些值转换为:

一个例子的痛苦 - 如果你是

如何将这些字符转换为php中列出的值?

Ped*_*ito 13

您可以使用mb_convert_encoding

$str = "an example pain— if you’re";
$str = mb_convert_encoding($str, "Windows-1252", "UTF-8");
echo $str;
//an example pain— if you’re
Run Code Online (Sandbox Code Playgroud)

演示:http :
//ideone.com/NsIb5x