Created
July 20, 2018 07:41
-
-
Save MathieuAuclair/a40e0fb778259b329cddbb9b5f85cb54 to your computer and use it in GitHub Desktop.
Check if a string is encoded in ASCII with javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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