Unicode UICF-16 Encoding

I have a wide char string - this is L "hao123-- ζˆ‘ ηš„ δΈŠη½‘ δΈ»ι‘΅" and it should be encoded in "hao123 - \ u6211 \ u7684 \ u4E0A \ u7F51 \ u4E3B \ u9875". I was told that the encoded string is a special format called "% uNNNN" for encoding Unicode UTF-16 code points. At this website , he tells me that JavaScript is running away. But I do not know how to encode it using C ++.

Is there a library there to make this work? or give me some advice.

Thanks to my friends!

+3
source share
2 answers

; , wchar_t 16 UTF-16. Windows Microsoft Visual ++ ( ++), wchar_t - 32 OS X GCC ( ). - , . Unicode (ICU) unicode. ( ): libiconv.


, ... , UTF-16, "unicode-escape ASCII" ( ASCII, "\ u", ), :

for each codepoint represented by the UTF-16 encoded string:
    if the codepoint is in the range [0,0x7F]:
       emit the codepoint casted to a char
    else:
       emit "\u" followed by the hexadecimal digits representing codepoint

, , ... UTF-16 , " ", . , " " " " . , UTF-8 UTF-16 ... 32 , . Unicode Transformation Format (UTF) , .

+2

\x \u.

0

Source: https://habr.com/ru/post/1742050/


All Articles