Talk about Char continuation

Source: Internet
Author: User

Part 1ArticleLet's talk about Char, which compares the GCC and VC compilers used on Linux and Windows respectively. What if both of them use the GCC compiler?

GCC memory in window:

In Linux and Windows, how does one implement the qstring of GCC and VC? Linux platform:

Windows:

On Linux and Windows platforms, qstring implementation is implemented by short. Each Chinese Character occupies two bytes and the encoding is UTF-8.

What about the qstring generated by using the VC compiler in windwos?

Note that the VC compiler 8 is saved as UTF-8 and gb2312, the char is still gb2312, wchar_t is Unicode, And the qstring is still two-byte short, but the encoding is gb2312.

To compile gb2312 text using mingw, you need to add compilation parameters. -Finput-charset = GBK. GCC stores the data in the same way regardless of the source code file format. For example, char: UTF-8, wchar_t: Unicode, qstring: Short UTF-8

Conclusion:

  • GCC uses UTF-8 to save char and Unicode to save whar_t on Windows and Linux platforms.
  • VC always uses GBK to save char and Unicode to save wchar_t
  • The internal encoding formats of GCC and VC are irrelevant to the source file storage encoding formats.
  • Qstring encoding is related to the compiler, but both use short as the container.

The implementation of the standard C ++ does not provide much support for wchar_t. VC has added a lot of wchar_t extension functions in the library, which brings some problems for cross-platform migration.

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.