PHP - utf8_decode() to wrong character

2019-04-15 03:00发布

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条回答
我只想做你的唯一
2楼-- · 2019-04-15 03:51

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);
查看更多
登录 后发表回答