VS2013 Qt5 MySQL Chinese coding problem

Source: Internet
Author: User

QT starts by default is Utf-8, and VS2013 default program is encoded as gb2312;

This will find the use of Chinese language when garbled.

There are generally two solutions:

1. When using Chinese, use Qtextcodec

Qtextcodec *gbk=qtextcodec::codecforname ("gb2312");

QString Str=gbk->tounicode ("Chinese");

This is more cumbersome to use, it is recommended to use the second

2. Change the "Newc++file.cpp" and "hfile.h" files in the "Microsoft Visual Studio 12.0\vc\vcprojectitems" directory. Add a similar to the inside:

#pragma once
#pragma execution_character_set ("Utf-8")
Force no Signature Utf-8

Such a sentence with Chinese or other multi-character encoding, and then save as 65001 Utf-8 no signature on OK.

Recommend this.

And then set MySQL to Utf-8 encoding so there's no problem.


VS2013 Qt5 MySQL Chinese coding problem

Related Article

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.