Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我的问题是当我解析来自 curl 的 xml 响应时,出于某种原因,我从 simplexml 获得的撇号字符是一些奇怪的字符。例如:
$xml = 新的 SimpleXMLElement($resp);
$xml->description 输出类似于:
在同意成为国王之手后,内德离开临冬城
SnowInferno 是对的,没有任何改变。只是您页面上声明的编码不是UTF-8,而是Windows-1252。为您的页面声明 UTF-8,它将起作用:
header("Content-Type: text/html; charset=utf-8"); $xml = new SimpleXMLElement($resp); $xml->description ouputs something like: