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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With