Dan Stern
Dan Stern

Reputation: 2167

special characters in facebook canvas

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('&Aacute;', '&aacute;','&eacute;','&iacute;','&oacute;','&uacute;','&nacute;',);

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?

Upvotes: 1

Views: 661

Answers (2)

Arazu
Arazu

Reputation: 441

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.

Upvotes: 0

Removed
Removed

Reputation: 1

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.

Upvotes: 1

Related Questions