Here is the javascript String prototype function extended to support Turkish characters.
String.prototype.toTRUppercase = function() {
var str = [];
for(var i = 0; i < this.length; i++) {
var code = this.charCodeAt(i);
var c = this.charAt(i);
if(code == 305) //ı
str.push(String.fromCharCode(73));
else if(code == 105) // i
str.push(String.fromCharCode(304));
else if(code == 287) // ğ
str.push(String.fromCharCode(286));
else if(code == 252) // ü
str.push(String.fromCharCode(220));
else if(code == 351) // ş
str.push(String.fromCharCode(350));
else if(code == 246) // ö
str.push(String.fromCharCode(214));
else if(code == 231) // ç
str.push(String.fromCharCode(199));
else if(code >= 97 && code <= 122)
str.push(c.toUpperCase());
else
str.push(c);
}
return str.join('');
}
Sample Usage
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script type="text/javascript">
String.prototype.toTRUppercase = function() {
var str = [];
for(var i = 0; i < this.length; i++) {
var code = this.charCodeAt(i);
var c = this.charAt(i);
if(code == 305) //ı
str.push(String.fromCharCode(73));
else if(code == 105) // i
str.push(String.fromCharCode(304));
else if(code == 287) // ğ
str.push(String.fromCharCode(286));
else if(code == 252) // ü
str.push(String.fromCharCode(220));
else if(code == 351) // ş
str.push(String.fromCharCode(350));
else if(code == 246) // ö
str.push(String.fromCharCode(214));
else if(code == 231) // ç
str.push(String.fromCharCode(199));
else if(code >= 97 && code <= 122)
str.push(c.toUpperCase());
else
str.push(c);
}
return str.join('');
}
</script>
</head>
<body>
<form>
<input type="text" onblur="this.value=this.value.toTRUppercase();"/>
</form>
</body>
</html>
Hiç yorum yok:
Yorum Gönder