[c/c++]_[vs2010 Use source code UTF8 Chinese string transcoding ANSI problem]

Source: Internet
Author: User


Scene:

1. Thought vs Set source file UTF8 encoding, the code string China appears in it must be UTF8 encoded. Unfortunately no, suppose source code appears in Chinese string, in memory bus code ANSI code.


Unicode (UTF8) code page (65001). Advanced Save Options settings from menu, file.


Examples:

Char path[] = "resources\\ chinese \ \"; for (int i = 0; i < strlen (path); ++i) {printf ("0x%x," (unsigned char) path[i]);}

View UTF8 file Hex 0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x73,0x5c,0x5c,0xe4,0xb8,0xad,0xe6,0x96,0x87,0x5c, 0X5C print out the memory: 0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x73,0x5c,0xd6,0xd0,0xce,0xc4,0x5c obvious "Chinese" file encoding is 0XE4,0XB8, 0xad,0xe6,0x96,0x87 the memory is loaded and becomes, the encoding is ANSI-encoded, which is the local code (GB2312). 0xd6,0xd0,0xce,0xc4 conclusion is: Do not appear in the source code of the UTF8 Chinese string, It will be code converted to ANSI encoding.


Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

[c/c++]_[vs2010 Use source code UTF8 Chinese string transcoding ANSI problem]

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.