Coming back to this years later to provide more up to date solution.
There is no need for the hack below,
just use
String.toLocaleUpperCase() and String.toLocaleLowerCase()
"din?".toLocaleUpperCase('tr-TR') // "D?N?"
All modern browsers support this now.
[ OLD, DO NOT USE THIS ]
Try these functions
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();
}
// Example
"D?N?".turkishToLower(); // => din?
"DIN?".turkishToLower(); // => d?n?
I hope they will work for you.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…