Created
October 5, 2014 14:02
-
-
Save borantula/945aae7f5ed0de0e8774 to your computer and use it in GitHub Desktop.
Turkish case conversion in JavaScript
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
//source: http://stackoverflow.com/questions/1850232/turkish-case-conversion-in-javascript | |
String.prototype.turkishToUpper = function(){ | |
var string = this; | |
var letters = { "i": "İ", "ş": "Ş", "ğ": "Ğ", "ü": "Ü", "ö": "Ö", "ç": "Ç", "ı": "I" }; | |
string = string.replace(/(([iışğüçö]))+/g, function(letter){ return letters[letter]; }) | |
return string.toUpperCase(); | |
} | |
String.prototype.turkishToLower = function(){ | |
var string = this; | |
var letters = { "İ": "i", "I": "ı", "Ş": "ş", "Ğ": "ğ", "Ü": "ü", "Ö": "ö", "Ç": "ç" }; | |
string = string.replace(/(([İIŞĞÜÇÖ]))+/g, function(letter){ return letters[letter]; }) | |
return string.toLowerCase(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment