PHP - utf8_decode() to wrong character

こ雲淡風輕ζ 提交于 2019-12-21 21:39:55

问题


Trying to use the Twitter search API. When I call utf8_decode on a re-tweeted tweet I get speech marks/quotes appear as question marks...

Code:

$output .= '
        <div class="leftcoltweet">
            <div class="timg">
                <a href="' . $account . '" target="_blank"><img src="' . $image .'"></a>
            </div>
            <div class="ttweet">
                ' . utf8_decode($tweet) . '
            </div>
            <div class="clr"></div>
            <div class="ttime">' . $time . '</div>
            <div class="clr"></div>
        </div>
    ';

Output:

RT @IVAOAERO: ?@FilipJonckers: We are aware of and working on a fix for the ATIS issue introduced after last nights network upgrade http://t.co/6FODzr0Y?

All other symbols display correctly.

Do I have to set a language to use? If you want to know the atom query I make or anything else then let me know.


回答1:


note that utf8_decode() works ONLY with iso-8859-1 (latin) encoded string. if you know the character set of the string, you can call:

echo iconv("THE_CHARSET","utf8",$tweet);


来源:https://stackoverflow.com/questions/10864044/php-utf8-decode-to-wrong-character

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!