Question

I'm working with ICU in a C++ library. How can I get the Unicode Hex value of a UChar? For example, 'a' should be equal to 0x0041 (http://www.unicode.org/charts/PDF/U0000.pdf).

Was it helpful?

Solution

How about something simple like

std::cout << std::hex << std::setw(4) << std::setfill('0')
          << static_cast<int>('a') << '\n';

Though it prints 0061 and not 0041, which is the correct hex value for a.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top