VC with Chinese and English \u format Unicode string to Unicode visible string

Source: Internet
Author: User

Java uses the UTF-8 format string, where Java communicates with C + + to convert UTF-8 strings to Unicode strings, such as "ABCDABCD Chinese people xiasha 123." After converting to Unicode, the appearance is as follows:

\u41\u42\u43\u44\u61\u62\u63\u64\u4e2d\u56fd\u4eba\u6c11\u4e0b\u6c99\u31\u32\u33\u2e\u676d\u5dde

VC in the following processing can be turned back

CString cxxclass::unicodetostring () {CString Strunicode = _t ("\\u41\\u42\\u43\\u44\\u61\\u62\\u63\\u64\\u4e2d\\ U56fd\\u4eba\\u6c11\\u4e0b\\u6c99\\u31\\u32\\u33\\u2e\\u676d\\u5dde "); INT iStart = 0, iend = 0; CString strtmp, Strout; TCHAR C; BOOL bEnd = false;for (INT i = 0; i < strunicode.getlength (); ++i) {iend = Strunicode.find (_t (' \\u '), IStart); if (Iend & Lt 0) {iend = Strunicode.getlength (); bEnd = TRUE;} strtmp = Strunicode.mid (IStart + 1, iend-istart-1), if (!strtmp.isempty ()) {swscanf_s (Strtmp.getbuffer (), _t ("%x"), & ; c); Strtmp.releasebuffer (); Strout + = C;} IStart = iend + 1;if (bEnd) {break;}} return strout;}

There should be a better way to welcome the exchange.

VC with Chinese and English \u format Unicode string to Unicode visible string

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.