How to verify browser support UTF-8 characters properly


Is there a way to identify whether the browser encoding is set to/supports "UTF-8" from Javascript?

I want to send "UTF-8" or "English" letters based on browser setting transparently (i.e. without asking the User)

Edit: Sorry I was not very clear on the question. In a Browser the encoding is normally specified as Auto-Detect (or) Western (Windows/ISO-9959-1) (or) Unicode (UTF-8). If the user has set the default to Western then the characters I send are not readable. In this situation I want to inform the user to either set the encoding to "Auto Detect" (or) "UTF-8".

Best Solution

First off, UTF-8 is an encoding of the Unicode character set. English is a language. I assume you mean 'ASCII' (a character set and its encoding) instead of English.

Second, ASCII and UTF-8 overlap; any ASCII character is sent as exactly the same bits when sent as UTF-8. I'm pretty sure all modern browsers support UTF-8, and those that don't will probably just treat it as latin1 or cp1252 (both of which overlap ASCII) so it'll still work.

In other words, I wouldn't worry about it.

Just make sure to properly mark your documents as UTF-8, either in the HTTP headers or the meta tags.

Related Question