Unsigned integer as UTF-8 value

后端 未结 4 1221
故里飘歌
故里飘歌 2021-02-03 16:46

assuming that I have

uint32_t a(3084);

I would like to create a string that stores the unicode character U+3084 which means that I

4条回答
  •  南笙
    南笙 (楼主)
    2021-02-03 17:04

    auto s = u8"\343\202\204"; // Octal escaped representation of HIRAGANA LETTER YA
    std::cout << s << std::endl;
    

    prints

    for me (using g++ 4.8.1). s has type const char*, as you'd expect, but I don't know if this is implementation defined. Unfortunately C++ doesn't have any support for manipulation of UTF8 strings are far as I know; for that you need to use a library like Glib::ustring.

提交回复
热议问题