Chinese garbled characters in DOS

Source: Internet
Author: User
Chinese characters in DOS are garbled. today, I am going to operate mysql databases in DOS. Chinese characters garbled during data insertion into tables. Both my database and table are in utf8 format.
My mysql is prepared in advance in the text, in the utf8 encoding format, then copy and paste it into DOS, and it becomes garbled. I tried to change the format of the dos encoding page to utf8 format. it should be okay, but every time I paste Chinese characters, the display is incomplete, resulting in similar garbled characters, as a result, the data cannot be inserted. some people say that the data can be minimized first and then maximized. but I inserted the data in several rows. I pasted the data and reported an error.

Thank you!


Reply to discussion (solution)

Nobody ??

This is the case when the code is minimized, but I have the code and need to run it in one breath.

Try inputting set names gbk in mysql editing
Can refer to this article http://blog.csdn.net/wzwsj1986/article/details/1723658

The command line client uses GBK encoding. no matter what encoding your table is, you must declare that the client is GBK encoded, that is, set names gbk;

Try inputting set names gbk in mysql editing
Can refer to this article http://blog.csdn.net/wzwsj1986/article/details/1723658



Both my database and table are in the utf8 encoding format. as you said, this direction should be used to change the encoding format, but I need DOS to work with my mysql encoding, instead of using mysql to work with DOS.

The command line client uses GBK encoding. no matter what encoding your table is, you must declare that the client is GBK encoded, that is, set names gbk;



The command in DOS can be set to the encoding format. in chcp 65001, the format of the DOS encoding page can be set to utf8. Now I have changed the DOS encoding format to utf8, and the formats of my database and data table are both utf8, so I want to maintain the utf8 format on both sides, in this way, no garbled characters will be inserted into the table. However, the actual situation is that when I paste the prepared SQL statement in utf8 format to DOS, the display of Chinese characters will be incomplete, just like garbled characters, I don't know whether the system uses it as garbled code. Then the data cannot be inserted.

Is it so heavy ??

"My mysql is prepared in advance in the text. it is in utf8 encoding format. then copy and paste it into DOS, and it becomes garbled"
I remember reading a blog post about utf8 encoding in Windows's built-in text editor, which seems to be something to do at the beginning, we recommend that you use another editor to generate SQL statements and test them in DOS .....

How to display UTF-8 characters in a DOS window

In the Chinese Windows system, if a file contains 8 bytes, the file content cannot be correctly displayed in the cmd.exe command line window (the so-called DOS window. By default, the code page used in the command line window is Chinese or American, that is, the code is a Chinese or Spanish character set.
If you want to correctly display UTF-8 characters, follow these steps:
1. open the cmd.exe command line window
2. use the chcp command to change the code page. the code page of the UTF-8 is 65001.
Chcp 65001
After this operation is performed, the code page is turned into a UTF-8. However, UTF-8 characters still cannot be correctly displayed in the window.
3. modify window properties and font
Right-click the title bar of the command line, select "property"-> "font", change the font to "Lucida Console" of True Type, and click "OK" to apply the property to the current window.
Then you can use the type command to display the content of the UTF-8 text file:
Type filename.txt
4. the above operations cannot completely solve the problem, because the displayed content may be incomplete. The command line window can be minimized first, and the file content is displayed completely.

See how complicated it is!

You have written SQL commands to files
Mysql> \. file name
Will it be executed? Why copy and paste

How to display UTF-8 characters in a DOS window

In the Chinese Windows system, if a file contains 8 bytes, the file content cannot be correctly displayed in the cmd.exe command line window (the so-called DOS window. By default, the code page used in the command line window is Chinese or American, that is, the code is a Chinese or Spanish character set.
If you want to correctly display UTF-8 characters, follow these steps:
1. open the cmd.exe command line window
2. use the chcp command to change the code page. the code page of the UTF-8 is 65001.
Chcp 65001
After this operation is performed, the code page is turned into a UTF-8. However, UTF-8 characters still cannot be correctly displayed in the window.
3. modify window properties and font
Right-click the title bar of the command line, select "property"-> "font", change the font to "Lucida Console" of True Type, and click "OK" to apply the property to the current window.
Then you can use the type command to display the content of the UTF-8 text file:
Type filename.txt
4. the above operations cannot completely solve the problem, because the displayed content may be incomplete. The command line window can be minimized first, and the file content is displayed completely.

See how complicated it is!

You have written SQL commands to files
Mysql> \. file name
Will it be executed? Why copy and paste



What do you mean by directly executing this file? I have never tried. maybe I can. But for example, not all contents in my file need to be executed? You only need to execute a piece of code? It is too troublesome to try again in DOS, but if you want to paste this piece of code, there will be problems. To put it bluntly, why can't DOS in utf8 format be pasted with Chinese content in utf8 format? I just want to understand this.


"My mysql is prepared in advance in the text. it is in utf8 encoding format. then copy and paste it into DOS, and it becomes garbled"
I remember reading a blog post about utf8 encoding in Windows's built-in text editor, which seems to be something to do at the beginning, we recommend that you use another editor to generate SQL statements and test them in DOS .....



I am not clear about the SQL statement stored in EditPlus. why is it similar to garbled characters when I paste Chinese characters? (I don't know if it is garbled, but I can only display it in half)

The command window is a legacy of ancient times, and it is normal to be unable to adapt to the modern environment.
You also know how tedious it is to modify the character set of the command window, so you should adapt to him instead of letting him adapt to you.

A set names gbk command can solve the problem, but you have to use UTF-8 for some reason.

Besides, there are many MySQL client tools. why do I have to throw it on cmd?

The command window is a legacy of ancient times, and it is normal to be unable to adapt to the modern environment.
You also know how tedious it is to modify the character set of the command window, so you should adapt to him instead of letting him adapt to you.

A set names gbk command can solve the problem, but you have to use UTF-8 for some reason.

Besides, there are many MySQL client tools. why do I have to throw it on cmd?



Okay... maybe this is the only thing we can do.
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.