im having problems with special characters in the facebook canvas.
Im retreiving the users friends who haven't installed the app and displaying them. However, when i display them, the special chars appear as if they where encoded differently.
For example, á appears as á, é as é and so on.
Iv tried some things that haven't worked:
<?
$search=array('Ã', 'á', 'é','Ã','ó','ú','ñ');
$replace=array('Á', 'á','é','í','ó','ú','ń',);
echo str_replace($search,$replace, $friend_name) ?>
<? echo htmlentities($friend_name) ?>
some more info: Im working with facebook's php sdk, and set mete tag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Thanks
EDIT: applied utf8_decode() and the problem was solved. Is there anyway of solving the problem without this function?
Smells like a character encoding issue (UTF, cp1252, etc) as opposed to an escaping issue ( \\htmlspecialchars
). Check your source and destination encodings; they're probably mismatched.
By the way, it's worth mentioning that the default internal encoding for PHP changed to UTF-8 as of version 5.4, so you may also be running into bugs caused by version mismatches.
You should encode that document UTF-8. It depends on the editor you use the way it encodes. In notepad++ there is a encoding tab and you should use UTF-8 without BOM. This fixed my problem with facebook.
Even though you set the meta tag it won't be enough, you should encode your document UTF-8. If you do this, it will save you from having to encode/decode most similar things.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.