How to convert a unicode string to its unicode escapes?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: here )? 回答1: Note this loops over UTF-16 code units, not actual code points. 回答2: I assume you're doing code-generation (of JavaScript, maybe?) QString is like a collection of QChar . Loop through the contents, and on each QChar call the unicode method to get the ushort (16-bit integer) value. Then format each character like "\\u%04X" , i.e. \u followed by the 4-digit hex value. NB. You may need to swap the two bytes (the two hex characters) to get the right result depending on the platform you're running on. 回答3: wchar_t *input; wstring