Set QT + MySql in arm_linux to display Chinese Characters

Source: Internet
Author: User

At the beginning, follow the steps in the blog http://www.linuxidc.com/linux/2011-05/35404.htmto set up armlinux, and then continue to find another example...

Try a variety of solutions, but most of them talk about windows or Linux (UBUNTU) practices. It is easy to say that it is difficult to do. Let's look at my experiences...

1. It is easy to operate in windows. First, you can display MySQL Chinese Characters in windows.

According to partition (partition _ partition )~, However, in an episode, garbled characters are displayed for more than four Chinese characters. It must be because the data length definition is too short to be modified...

Mysql> DESC table_name;

...

Mysql> alter table 'test'. 'acquisitions 'change column 'unit ''unit' varchar (112) null default null;

Test

OK!

2. In arm, it is very difficult to understand what is done according to methods,

1) in the main function of Main. cpp of the QT program, the three sentences of qtextcodec ''' are as follows:

  1. IntMain (IntArgc,Char* Argv [])
  2. {
  3. Qapplication A (argc, argv );
  4. Qtextcodec * codec = qtextcodec: codecforname ("UTF-8 ");
  5. Qtextcodec: setcodecforcstrings (codec );
  6. Qtextcodec: setcodecfortr (codec );
  7. Mainwindow W;
  8. W. Show ();
  9. ReturnA.exe C ();
  10. }

2) After setting the database in your program code, add db.exe C ("set names 'latin1'"); // use the database's Latin1 encoding directly.

However, it may be that the compiled arm version of MySQL is not the same as that of ubuntu. Let's look at its character set:

View the Current Character Set settings of MySQL:
Mysql> show variables like 'character % ';
+ -------------------------- + ---------------------------------------- +
| Variable_name | value |
+ -------------------------- + ---------------------------------------- +
| Character_set_client | gb2312 |
| Character_set_connection | gb2312 |
| Character_set_database | gb2312 |
| Character_set_filesystem | binary |
| Character_set_results | gb2312 |
| Character_set_server | gb2312 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/local/MySQL/share/MySQL/charsets/|
+ -------------------------- + ---------------------------------------- +
8 rows in SET (0.00 Sec)

What should I do if the default character set is Latin1? Read a blog post and say,

........................... Reference section ..............................

If character_set_client, character_set_connection, and character_set_results are modified to utf8,

Modify the my. CNF file in Linux (it seems that it is okay to change the file to utf8). The file is usually located at/etc/MySQL/My. CNF.

After opening my. CNF,

Find the client configuration [client] and add it below
Default-character-set = Latin1 set the default character set to Latin1
Add in [mysqld]
Default-character-set = Latin1 default character set is Latin1
Init_connect = 'set names latin1' (sets Latin1 encoding when connecting to the MySQL database to run the MySQL database as Latin1)

After modification, restart MySQL and check whether show variables like 'character % 'is the same as Figure 1.

....................... End .................................

After setting, it still does not work .... Boring ing

Things: if it doesn't work, you can try utf8. How can you set it?

1. Set character_set_client = utf8 in the command line... Set other settings in sequence, and set the alter table user_info default Character Set utf8; test, no, run the command line to view the character set. mysql> show variables like 'character % ';
+ -------------------------- + ---------------------------------------- +
| Variable_name | value |
+ -------------------------- + ---------------------------------------- +
| Character_set_client | gb2312 |
| Character_set_connection | gb2312 |
| Character_set_database | gb2312 |
| Character_set_filesystem | binary |
| Character_set_results | gb2312 |
| Character_set_server | gb2312 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/local/MySQL/share/MySQL/charsets/|
+ -------------------------- + ---------------------------------------- +
8 rows in SET (0.00 Sec)
Not changed ....

2. Run mysql> set names 'utf8'. Then run the command to view the character set.

Mysql> set names 'utf8 ';
Query OK, 0 rows affected (0.00 Sec)

Mysql> show variables like 'character % ';
+ -------------------------- + ---------------------------------------- +
| Variable_name | value |
+ -------------------------- + ---------------------------------------- +
| Character_set_client | utf8 |
| Character_set_connection | utf8 |
| Character_set_database | gb2312 |
| Character_set_filesystem | binary |
| Character_set_results | utf8 |
| Character_set_server | gb2312 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/local/MySQL/share/MySQL/charsets/|
+ -------------------------- + ---------------------------------------- +
8 rows in SET (0.00 Sec)

Character_set_client, character_set_connection, and character_set_results are changed. Can I try to modify all the changes but they are not saved after the release? What should I do? The specific saving method is not found, and I don't know why it was executed. I went to the database next time and restored the original character set. We can change our mindset and set all the settings at each running time,

After the database connection is successful

    db.exec("SET NAMES 'utf8'");

How can this problem be solved?
Db.exe C ("set character_set_database = utf8 ");
Db.exe C ("set character_set_server = utf8 ");

In this way, all the character sets of each variable are set. If you try again, you have to try again to find the answer. This may be a magic weapon for stupid birds to fly first ~ Haha, nonsense...

This setting is successful !!!

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.