F
Fabio
I been looking for a way to list the letters of the English Letter in
Java. It seems that they have forgot to add such feature.
I am working in a internationalized application that have a bar with
the letters of any alphabet (let's say just Western European). The
user clicks in
one of those letters and then I display a list of options that start
with that
letter.
I have not found a way to extract the letters of a particular
language.
Even worst it seems that the methods in the Character class do not
work properly. The code below will print characters that are not
letter or digit
to the screen. Even if I could get the character I have not seen a
constructor
that takes the Locale and gives me a Character set for a particular
language.
I know there are Character set for different encodings such 8859-1,
etc. But
this is not what I need because in that encoding there are all the
languages.
Has anybody done this before?
Thank,
Fabio
public class CharDemo2 {
public static void main(String args[]) {
int dig_count = 0;
int def_count = 0;
Character c = null;
for (int i = 0; i <= 0xff; i++) {
c = new Character((char)i);
if (Character.isDigit(c.charValue())) {
dig_count++;
}
if (Character.isLetter(c.charValue())) {
def_count++;
}
if(!Character.isLetterOrDigit(c.charValue()))
System.out.print(" i="+i+" "+c.charValue());
if(i%10 == 0)
System.out.println();
}
System.out.println();
System.out.println("number of digits = " + dig_count);
System.out.println("number of defined = " + def_count);
}
}
Java. It seems that they have forgot to add such feature.
I am working in a internationalized application that have a bar with
the letters of any alphabet (let's say just Western European). The
user clicks in
one of those letters and then I display a list of options that start
with that
letter.
I have not found a way to extract the letters of a particular
language.
Even worst it seems that the methods in the Character class do not
work properly. The code below will print characters that are not
letter or digit
to the screen. Even if I could get the character I have not seen a
constructor
that takes the Locale and gives me a Character set for a particular
language.
I know there are Character set for different encodings such 8859-1,
etc. But
this is not what I need because in that encoding there are all the
languages.
Has anybody done this before?
Thank,
Fabio
public class CharDemo2 {
public static void main(String args[]) {
int dig_count = 0;
int def_count = 0;
Character c = null;
for (int i = 0; i <= 0xff; i++) {
c = new Character((char)i);
if (Character.isDigit(c.charValue())) {
dig_count++;
}
if (Character.isLetter(c.charValue())) {
def_count++;
}
if(!Character.isLetterOrDigit(c.charValue()))
System.out.print(" i="+i+" "+c.charValue());
if(i%10 == 0)
System.out.println();
}
System.out.println();
System.out.println("number of digits = " + dig_count);
System.out.println("number of defined = " + def_count);
}
}