2012-06-02 32 views
2

試圖使用Twitter搜索API。當我打電話utf8_decode上重新啾啾鳴叫,我得到的語音標記/報價顯示爲問號......PHP-utf8_decode()爲錯誤字符

代碼:

$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> 
    '; 

輸出:

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

所有其他符號正確顯示。

我必須設置要使用的語言嗎?如果你想知道我製作的原子查詢或其他東西,請告訴我。

+1

請你能提供的一些代碼,可以通過人的努力幫助回答這個問題可以運行一些例子嗎?瞭解Twitter數據如何到達這一點很重要。 –

+2

ISO 8859-1的Unicode是有損轉換,因爲ISO 8859-1只包含Unicode的一小部分(即前256個字符)。你看到的是這種有損轉換的結果。你爲什麼不使用UTF-8呢? – Gumbo

回答

8

請注意,utf8_decode()工程只有與iso-8859-1(拉丁)編碼的字符串。 如果你知道字符集的字符串,您可以撥打:

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

這是爲什麼? – Bytemain

+0

[here](http://php.net/manual/en/function.utf8-decode.php)。 – 2012-06-02 16:35:24