Skip to content

Instantly share code, notes, and snippets.

@mit4dev
Forked from barlas/ready-tr-lower-upper-func.js
Created February 14, 2020 08:21
Show Gist options
  • Save mit4dev/de308254e4cc6757c1e5d8e3184037d2 to your computer and use it in GitHub Desktop.
Save mit4dev/de308254e4cc6757c1e5d8e3184037d2 to your computer and use it in GitHub Desktop.
javascript - Turkish character lowercase and uppercase functions.
String.prototype.turkishToLower = function(){
var string = this;
var letters = { "İ": "i", "I": "ı", "Ş": "ş", "Ğ": "ğ", "Ü": "ü", "Ö": "ö", "Ç": "ç" };
string = string.replace(/(([İIŞĞÜÇÖ]))/g, function(letter){ return letters[letter]; })
return string.toLowerCase();
}
String.prototype.turkishToUpper = function(){
var string = this;
var letters = { "i": "İ", "ş": "Ş", "ğ": "Ğ", "ü": "Ü", "ö": "Ö", "ç": "Ç", "ı": "I" };
string = string.replace(/(([iışğüçö]))/g, function(letter){ return letters[letter]; })
return string.toUpperCase();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment