Created
February 12, 2019 16:13
-
-
Save kyle-west/7401fd24f11fa38f11b9b068e895408d to your computer and use it in GitHub Desktop.
String Class Extension for determining if a string has unicode characters or not.
This file contains hidden or 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
/** | |
* @method containsUnicode | |
* @extends {String} | |
* | |
* @returns {Boolean} - True iff <String> contains one or more Unicode Characters | |
*/ | |
String.prototype.containsUnicode = function () { | |
return this.split('').reduce((a,x)=> a || x.charCodeAt(0) > 255, false) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: