In Java, I was able to determine if a particular character was for example, a Japanese Kanji using Unicode.blockOf(Character). I'm trying to do the same for a QChar, but couldn't find a relevant function to do this. I'm wondering if I just missed it, or will I have to roll my own, and if so - how?
How can I determine the Unicode block of a character, specifically a Qt QChar?
901 Views Asked by neuviemeporte At
2
There are 2 best solutions below
1

I don't know if there's a better Qt specific approach. If there isn't you could try using ICU rather than rolling your own solution.
ICU has both a "C/C++" version and a Java version. The Java version of ICU actually shares a common ancestor with some of the Java standard libraries for i18n/l10n, so the C/C++ version will hopefully be easy for you to figure out.
There is QChar::Category however it does not provide everything you need.
For checking whether a char is in certain range, you could write a function like this:
You could then use it like this:
Of course you could go further and make it more abstract and enumerate the ranges:
And here is the list of the Unicode Blocks