rgarrot Posted March 17, 2012 Share Posted March 17, 2012 Hi People! I'm from Brazil and I'm having some troubles with special characters when i'm getting an object from a REST web service. after I send the GET method, I receive the return, and at the message body... I should get this (in portuguese): "União da Ilha" "Braços abertos" But i'm getting: "Un]e0o da ilha" "Bra{f3os abertos" It is the special latim characters. I've tried almost all codification methods, like utf8_encode, htmlentities, etc. someone could help me ? thks a lot!! (and sry my poor english). Quote Link to comment https://forums.phpfreaks.com/topic/259094-special-characters/ Share on other sites More sharing options...
requinix Posted March 17, 2012 Share Posted March 17, 2012 Normally mojibake shows as unusual characters, not things you'd find on a keyboard. Can you post what you get when you run echo bin2hex($string); (if $string is the response)? Without any modifications to it. Also try using mb_detect_encoding on that response. Sometimes it can tell you what encoding the string is, other times it doesn't know. Quote Link to comment https://forums.phpfreaks.com/topic/259094-special-characters/#findComment-1328310 Share on other sites More sharing options...
rgarrot Posted March 17, 2012 Author Share Posted March 17, 2012 with mb_detect_encoding, sometimes i'm getting ASCII and sometimes UTF-8. ASCII - Uni;e0o da Ilha ASCII - Unidos da Tijuca ASCII - Portela ASCII - Unidos de Vila Isabel ASCII - Uni;e0o do Parque Curicica UTF-8 - Uni;e0o de Jacarepagu80 ASCII - Infantes do Lins and with bin2hex() : 556e693b65306f20646120496c6861 - G.R.E.S Uni;e0o da Ilha do Governador 556e69646f732064612054696a756361 - G.R.E.S Unidos da Tijuca 506f7274656c61 - G.R.E.S Portela 556e69646f732064652056696c612049736162656c - G.R.E.S Unidos de Vila Isabel 556e693b65306f20646f20506172717565204375726963696361 - G.R.E.S Uni;e0o do Parque Curicica 556e693b65306f206465204a616361726570616775103263 - G.R.E.S Uni;e0o de Jacarepagu80 472e522e432e452e532e4d2e20496e66616e74657320646f204c696e73 - Infantes do Lins any idea? Quote Link to comment https://forums.phpfreaks.com/topic/259094-special-characters/#findComment-1328483 Share on other sites More sharing options...
requinix Posted March 18, 2012 Share Posted March 18, 2012 I can't tell what it is. Accented characters are represented by some kind of a control character (like a semicolon or 0x10) followed by two hex digits but I don't see a correlation between those and the original character. 0x3B 0x65 0x30 = ã 0x10 0x32 0x63 = á I suggest you contact the people who own the web service and ask them about this. Short of that you can manually substitute those sequences with (for example) strtr() like $string = strtr($string, array( "\x3B\x65\x30" => "ã", "\x10\x32\x63" => "á" )); If you do this, be sure to save the file with this code in whatever encoding you want the characters to be. So save the file as UTF-8 if you want that, or ISO 8859-1 if you want that. Quote Link to comment https://forums.phpfreaks.com/topic/259094-special-characters/#findComment-1328608 Share on other sites More sharing options...
rgarrot Posted March 18, 2012 Author Share Posted March 18, 2012 thx you a lot man. I'm replacing one by one by myself like you suggested. Quote Link to comment https://forums.phpfreaks.com/topic/259094-special-characters/#findComment-1328631 Share on other sites More sharing options...
rgarrot Posted March 18, 2012 Author Share Posted March 18, 2012 OMG! sometimes the same character is with different code... I replaced: Acadêmicos da Abolição - 41636164c382c2ab36396d69636f732064612041626f6c697865663b63306f - but: Cora}65?es Unidos do Amarelinho - 436f72617d36353f657320556e69646f7320646f20416d6172656c696e686f "Corações Unidos do Amarelinho" The "ç" is with a different codification... Quote Link to comment https://forums.phpfreaks.com/topic/259094-special-characters/#findComment-1328639 Share on other sites More sharing options...
requinix Posted March 18, 2012 Share Posted March 18, 2012 It's okay if one character has many encodings as long as each encoding only corresponds to one character. But that is weird. Again I suggest you contact those people and find out what's going on. Quote Link to comment https://forums.phpfreaks.com/topic/259094-special-characters/#findComment-1328673 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.