Last active
August 29, 2015 14:02
-
-
Save EpokK/907bb3bc5810f8d3d0e9 to your computer and use it in GitHub Desktop.
Manual lowercase / uppercase
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
String.prototype.manualLowercase = function(s) { | |
return (typeof s === 'string') ? s.replace(/[A-Z]/g, function (ch) { | |
return String.fromCharCode(ch.charCodeAt(0) | 32) | |
}) : s; | |
}; | |
String.prototype.manualUppercase = function (s) { | |
return (typeof s === 'string') ? s.replace(/[a-z]/g, function (ch) { | |
return String.fromCharCode(ch.charCodeAt(0) & ~32) | |
}) : s; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment