[請益] 資料庫包含中文,輸出XML 亂碼

看板PHP作者 (央)時間14年前 (2011/09/22 00:29), 編輯推噓0(004)
留言4則, 2人參與, 最新討論串1/1
請問一下,如我資料庫裡有中文, 我知道輸出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

09/22 00:36, , 1F
你原始編碼是啥?
09/22 00:36, 1F

09/22 00:59, , 2F
我用Notepad++ 看是ANSI,我有轉UTF-8都沒用...
09/22 00:59, 2F

09/22 09:14, , 3F
那資料庫內的文字編碼呢?
09/22 09:14, 3F

09/23 03:45, , 4F
utf8_general_ci 這個
09/23 03:45, 4F
文章代碼(AID): #1EUX3iEL (PHP)
文章代碼(AID): #1EUX3iEL (PHP)