| 
 | 
  This is my name - 2009-08-05 20:31:18  
When I use... for example, e accute, (é) and any other accute character I am getting parts of my tweet truncated. 
 
particularly, the truncated part is always after the special character. I suspect it has something to do with urlencode(). 
 
I also suspect that the use of that function is mandatory... ? any other optional url encoding function usabe? Such as rawurlencode()? or a custom function? 
  
  Valmy Gomes - 2009-10-01 03:04:02 -  In reply to message 1 from This is my name 
Hi. This my solution: 
 
function specialtwitter ($text) { 
    $text = htmlentities($text); //to convert the simple spec chars 
    $search = array('á','à','ã','â','é','ê','í','ó','ô','õ','ú','ü','ç','Á','À','Ã','Â','É','Ê','Í','Ó','Ô','Õ','Ú','Ü','Ç'); 
    $replace = array('á  ','à  ','ã  ','â  ','é  ','ê  ','í  ','ó  ','ô  ','õ  ','ú  ','ü  ','ç  ','Á  ','À  ','Ã  ','Â  ','É  ','Ê  ','Í  ','Ó  ','Ô  ','Õ  ','Ú  ','Ü  ','Ç  '); 
    $text = str_replace($search, $replace, $text); 
    return $text; 
} 
  
  Valmy Gomes - 2009-10-01 03:09:04 -  In reply to message 1 from This is my name 
Please, the correte custom function is this: 
 
function specialtwitter ($text) { 
    $search = array('á','à','ã','â','é','ê','í','ó','ô','õ','ú','ü','ç','Á','À','Ã','Â','É','Ê','Í','Ó','Ô','Õ','Ú','Ü','Ç'); 
    $replace = array('á  ','à  ','ã  ','â  ','é  ','ê  ','í  ','ó  ','ô  ','õ  ','ú  ','ü  ','ç  ','Á  ','À  ','Ã  ','Â  ','É  ','Ê  ','Í  ','Ó  ','Ô  ','Õ  ','Ú  ','Ü  ','Ç  '); 
    $text = str_replace($search, $replace, $text); 
    return urldecode($text); 
} 
 
Good Luck 
  
  This is my name - 2009-10-01 12:26:23 -  In reply to message 3 from Valmy Gomes 
Thankyou for your reply! 
While you gave it up to me, I arrived to a similar conclusion as far as replacing characters goes. 
 
I am replacing my literal accute characters with HTMLentities, which allows the class to successfully URLencode the accute characters.
 
So instead of replacing them with the unaccute versions of the character I am replacing like this:
 
$search = array('á','é''í','Á' ... ); 
$replace = array('á','é','í','Á');
 
For a listing of all html entities, see the following URL:
 w3schools.com/tags/ref_entities.asp
My custom function is as follows: 
   function acutereplace($txt){ 
      $find = array("/á/","/é/","/í/","/ó/","/ú/","/Á/","/É/","/Í/","/Ó/","/Ú/","/\.\.\./","/!/","/¡/","/ñ/","/Ñ/"); 
      $replace = array("á","é","í","ó","ú","Á","É","Í","Ó","Ú","","","","ñ","Ñ"); 
      $txt = preg_replace($find,$replace,$txt); 
      return $txt; 
   }
 
Then I modified the update function as follows: 
      $post_data = "status=" . urlencode($this->acutereplace($new_status));
 
This worked perfectly and my tweets enjoy acute characters when I tweet content from my website.
 
Thanks again for your reply, I am sorry I did not update my question earlier... I had forgotten about it... :)  
  
  Thomas Omerzu - 2010-03-22 17:09:21 -  In reply to message 4 from This is my name 
Twitter expects UTF-8 encoding for special characters. 
 
Thus another possible solution is to replace 
 
$post_data = "status=" . urlencode($new_status); 
 
with 
 
$post_data = "status=" . rawurlencode(mb_convert_encoding($new_status,"UTF-8","ISO-8859-1")); 
 
where you might want to exchange "ISO-8859-1" with your local character set encoding. 
 
  
  Brunno dos Santos - 2010-07-22 14:54:31 -  In reply to message 5 from Thomas Omerzu 
Thanks, this solution works to me xD 
  
   |