Locale specific lowercase/uppercase string manipulation in JavaScript
How can we entertain locale specific strings/character uppercase and lowercase manipulations in JavaScript? Like for example, Java provides java.lang.Character class for locale specific manipulations and the some of the methods are as follows:
toUpperCase(char ch) --> converts a unicode character to uppercase
toLowerCase(char ch) --> converts a unicode character to lowercase
(the language specific uppercase/lowercase is handled automatically)
Similarly,
- isUpperCase(char ch)
- isLowerCase(char ch)
are also available.
The coding example is as follows:
/*This is a greek character*/
ch='\u03B4';
System.out.println(ch);
System.out.println("Is Character = "+ Character.isLetter(ch));
System.out.println("Is Digit = " + Character.isDigit(ch));
System.out.println("Upper case = " + Character.toUpperCase(ch));
System.out.println();
Its output is as follows:
δ
Is Character = true
Is Digit = false
Upper case = Δ
See, the upperc开发者_如何学编程ase character is entirely different from the lowercase character. Now, if we want this functionality in JavaScript, do we any way?
Thank you in anticipation
Hmm, following works like a charm in javascript (tested in Firebug console in Firefox 6):
ch='\u03B4'; // δ
ch_up = ch.toUpperCase() //ch_up is now: "Δ"
ch_down = ch_up.toLowerCase() // ch_down is now "δ"
精彩评论