Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a Java character is a currency symbol

I have to perform a check on a character variable to see whether or not it is a currency symbol. I have discovered the Character.UnicodeBlock.CURRENCY_SYMBOLS constant however I am unsure of how to use this to determine whether or not the character is in that block.

If anyone has done this before help would be much appreciated.

Thanks

like image 606
Scottm Avatar asked Apr 06 '09 13:04

Scottm


1 Answers

Yep, according to Java API - that's the constant you are looking for.

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

char c = '$';
System.out.println(Character.getType(c) == Character.CURRENCY_SYMBOL);
// prints true
like image 59
Yuval Adam Avatar answered Nov 03 '22 00:11

Yuval Adam