开发者

Convert char to lower case in J2ME without using the Character class

开发者 https://www.devze.com 2023-01-16 12:12 出处:网络
I\'d like to convert a char to lower case in a J2ME app. The usual Character.toLowerCase() doesn\'t work for an arbitrary Unicode c开发者_运维技巧haracter in J2ME, so I need some light API, or, prefer

I'd like to convert a char to lower case in a J2ME app. The usual Character.toLowerCase() doesn't work for an arbitrary Unicode c开发者_运维技巧haracter in J2ME, so I need some light API, or, preferably, a piece of code that would do so.

Thanks!


Based on the toLowerCase() method from Character in JavaSE JDK:

char lowerChar = (char)CharacterData.of((int)upperChar).toLowerCase((int)upperChar);

You can read the source code from the JDK and understand what is really done here and apply the same thing with your own classes in JME.


Resources :

  • grepcode - Character.toLowerCase()


char toLowerCase(char c){
    if(c>=97 && c<=122)
        return (char) (c-32);
    else
        return c;
}


I just copied some of the stuff from Java SE 1.3 and included it in my J2ME app. Generally, it's a few methods and three big arrays from the Character class.

0

精彩评论

暂无评论...
验证码 换一张
取 消