0
votes

I have a unicode character code point stored as a string.

std::string code = "0663";

I need to decode it into utf8 and get as a standard std::string using the ICU library.

I decided to use ICU to get a cross-platform bit-independent solution.

1
Is the string meant to represent U+0663 (٣ 'ARABIC-INDIC DIGIT THREE')? - Tom Blodget
Yes, I had an Arabic character unicode codepoint, but I received it as a string, contains number. - Anna

1 Answers

2
votes

Untested:

  1. Convert the string into a int32_t.
  2. Treat the int32_t as a UChar32.
  3. Create a UnicodeString with UnicodeString::setTo from the UChar32.
  4. Create a string object with UnicodeString::toUTF8String from the UnicodeString.