How to check if a Java symbol is a currency symbol

I need to do a character variable check to see if it is a currency symbol. I found a constant Character.UnicodeBlock.CURRENCY_SYMBOLS, but I'm not sure how to use it to determine if a character is in this block.

If someone did this before help would be greatly appreciated.

thanks

+5
source share
1 answer

Yep, according to the Java API, is the constant you're looking for.

To get the type char, use the static method Character.getType(c):

char c = '$';
System.out.println(Character.getType(c) == Character.CURRENCY_SYMBOL);
// prints true
+15
source

All Articles