utf-8到iso-8859-1编码问题 [英] utf-8 to iso-8859-1 encoding problem

查看:186
本文介绍了utf-8到iso-8859-1编码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在另一个网站上从rss feed预览最新的帖子。该Feed是UTF-8编码的,而网站是ISO-8859-1编码。显示标题时,我正在使用;

I'm trying preview the latest post from an rss feed on another website. The feed is UTF-8 encoded, whilst the website is ISO-8859-1 encoded. When displaying the title, I'm using;

 $post_title = 'Blogging â€" does it pay the bills?';

 echo mb_convert_encoding($post_title, 'iso-8859-1','utf-8');

 // returns: Blogging ? does it pay the bills?
 // expected: Blogging - does it pay the bills?

请注意,我期望的连字符不是一个正常的减号,而是一些大屁股短跑。那么,还有几个像素长。 :)不知道如何用它来描述我的键盘不能产生这个字符...

Note that the hyphen I'm expecting isn't a normal minus sign but some big-ass uber dash. Well, a few pixels longer anyway. :) Not sure how else to describe it as my keyboard can't produce that character...

推荐答案

我怀疑你的意思一个Em Dash( - )。 ISO-8859-1不包括这个字符,所以你不会有太多的运气把它转换成编码。

I suspect you mean an Em Dash (—). ISO-8859-1 doesn't include this character, so you aren't going to have much luck converting it to that encoding.

你可以使用 htmlentities(),但我建议将ISO-8859-1移除到UTF-8出版。

You could use htmlentities(), but I'd suggest moving off ISO-8859-1 to UTF-8 for publication.

这篇关于utf-8到iso-8859-1编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆