Forum Moderators: coopster
I have read in a website that when using it is recommended to indicate the character encoding after the function
e.g.
html_entity_decode($var,ENT_QUOTES [, character_encoding]);
I have also read in this topic that the utf-8 encoding is the safest as it is now recognised worlwide (though there are still some problem with Asian countries)
My questions :
1/ Should I indicate the encoding in my statement?
2/ Is utf-8 really safe worldwide?
3/ If not, what about allowing the user to modify the encoding in its profile page (assing a variable) and then use the variable to all entity functions? Or can I forget this coz it has no use?
Thanks
1. If the character encoding for source and output are both ISO-8859-1 or ASCII, you will be fine. If the encoding is UTF-8 (or even Windows-1252) but you are only using characters from the ISO-8859-1 subset, you'll be okay too. If, however, you are using UTF-8 or Windows-1252 characters that are not part of the ISO-8859-1 set, I think you should be explicit about the encoding both in the function calls and using one of the approved methods for your page itself.
2. More and more so. If you want an encoding that is as universal as possible, utf-8 or one of the other unicode versions is your best bet. I think you may be right that there are still some older systems that use other encodings.
3. Any user who knows what encoding they use is going to be a rare bird. The rare ones that would know how to do this will also know how to override the automatic encoding detection in their browser and manually select and encoding, which is easy to do in FF and IE and probably all the browsers that count.
Like I said, I'm not familiar with your exact situation, so you can take all that with a grain of salt. Those are just my gut reactions.