简体   繁体   English

西班牙语字符不正确

[英]Spanish characters are incorrect

I downloaded a page with cURL and parsed the html with the "PHP Simple HTML DOM Parser". 我下载了带有cURL的页面,并使用“ PHP Simple HTML DOM Parser”解析了html。 The issue is when it displays the outer html of the element, the Spanish characters are incorrect. 问题是当它显示元素的外部html时,西班牙语字符不正确。 For example: 例如:

The original text 原文

la puja por la compra de los derechos de publicación ha sido la más reñida del año. 拉普亚波尔卡德拉斯洛斯德雷克索斯公共服务公司

The displayed text 显示的文字

la puja por la compra de los derechos de publicación ha sido la más reñida del año. 拉普亚波尔卡德拉斯洛斯德雷克索斯的公共场所,西哈拉西米拉的reñida delaño。

What would cause the letters to changed? 什么会导致字母更改?

I'm pretty sure that because it's appearing as multiple characters in the output this is occuring because you're trying to display some multi-byte UTF8 characters in a single-byte charset (probably ISO-8859-1). 我很确定这是因为它在输出中显示为多个字符,这是因为您正试图在单字节字符集中显示一些多字节UTF8字符(可能是ISO-8859-1)。

Have a look at this blog post that I wrote a while ago which should talk you through all of the potential problem areas. 看看我前一段时间写的这篇博客文章 ,它应该与您讨论所有潜在的问题区域。

不正确的字符编码-确保整个编码一致,我建议使用UTF-8

U have to determine what is the encoding of downloaded page and then (by iconv for example) convert it to your encoding. 您必须确定下载页面的编码是什么,然后(例如通过iconv)将其转换为您的编码。

See PHP: Convert curl_exec output to UTF8 请参见PHP:将curl_exec输出转换为UTF8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM