Skip to content

Instantly share code, notes, and snippets.

@MathieuAuclair
Created July 20, 2018 07:41
Show Gist options
  • Save MathieuAuclair/a40e0fb778259b329cddbb9b5f85cb54 to your computer and use it in GitHub Desktop.
Save MathieuAuclair/a40e0fb778259b329cddbb9b5f85cb54 to your computer and use it in GitHub Desktop.
Check if a string is encoded in ASCII with javascript
isAscii("é") //false
function isAscii(str) {
for (var i = 0, strLen = str.length; i < strLen; ++i) {
if (str.charCodeAt(i) > 125) return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment