作者oao54bb (央)
看板PHP
標題[請益] 資料庫包含中文,輸出XML 亂碼
時間Thu Sep 22 00:29:28 2011
請問一下,如我資料庫裡有中文,
我知道輸出XML時,顯示會亂碼。
可是我在輸出時用了 utf8_encode ,卻沒任何改善。
以下是我原始程式,我該怎麼修改我的程式碼呢...
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("vName",$row['vName']);
$newnode->setAttribute("vSummary", $row['vSummary']);
$newnode->setAttribute("Add", $row['Add']);
$newnode->setAttribute("Tel", $row['Tel']);
$newnode->setAttribute("vImg1", $row['vImg1']);
$newnode->setAttribute("vLat", $row['vLat']);
$newnode->setAttribute("vLng", $row['vLng']);
}
echo $dom->saveXML();
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.46.136.139
1F:→ gname:你原始編碼是啥? 09/22 00:36
2F:→ oao54bb:我用Notepad++ 看是ANSI,我有轉UTF-8都沒用... 09/22 00:59
3F:→ gname:那資料庫內的文字編碼呢? 09/22 09:14
4F:→ oao54bb:utf8_general_ci 這個 09/23 03:45