php 在php中将latin1字符串转换为utf8
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12939075/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
convert latin1 string to utf8 in php
提问by aLFaRSi
Possible Duplicate:
Convert utf8-characters to iso-88591 and back in PHP
i have this php file that connect to my MySQL BD , the BD callation is latin1_swedish_ci
我有这个连接到我的 MySQL BD 的 php 文件,BD 调用是 latin1_swedish_ci
this is my php code :
这是我的 php 代码:
<?php
$con = mysql_connect("localhost","root","");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("ttbfb", $con);
$result = mysql_query("SELECT * FROM news");
while($row = mysql_fetch_array($result)) {
echo $row['name'];
}
mysql_close($con);
?>
how can i convert the $row['name'] string into utf8 before i get the echo ?
在得到回声之前,如何将 $row['name'] 字符串转换为 utf8 ?
回答by gapple
Options for converting encodings are provided in Convert utf8-characters to iso-88591 and back in PHP
Convert utf8-characters to iso-88591 and back in PHP中提供了转换编码的选项

