Friday 15 March 2013

string - Check for non-UTF8 characters in Javascript -


Here's the quick question, which would be the best way to write a function in javascript, and return true if there is a non -Utf is not 8 characters, and is otherwise wrong? I'm not looking for any characters to replace, I just want to know that in the input string a non-UTF8 character (and then moving the user to warn through a popup window or any other form validation has gone). Hope this is not a robber ... thanks!

The JavaScript string is composed of Unicode characters. All Unicode characters are encoded in UTF-8. Therefore, by definition, Javascript can not contain "non-UTF8 characters" in a string.

No comments:

Post a Comment