Questions about MySQL encoding

Source: Internet
Author: User
Tags import database
We now every day from the Japanese website to download an order TXT file, and then import into the database through PHP, and now each time you have to use Notepad to turn txt into utf-8 after the import is not garbled, direct import is garbled, how can I use Notepad to transcode, with PHP transcoding on the line???

Here are some information for the big guys to help analyze
Server CharacterSet Latin1
Db CharacterSet Latin1
Client Chatacterset Latin1
Conn. Chatacterset latin1



Character_set_client latin1
Character_set_connection latin1
Character_set_database latin1
Character_set_filesystem latin1
Character_set_results latin1
Character_set_server latin1
Character_set_system latin1
Character_sets_dir latin1

Here are some of the code
mysql_query ("Set names Utf-8"), $ship _address3=mb_convert_encoding (Addslashes ($u []), ' UTF-8 ', ' auto ');


Reply to discussion (solution)

Whether to transcode, how to transcode, depending on the original data
You say "Use Notepad to turn txt into utf-8", so when you open this file with Notepad, can you display the content correctly? No garbled characters?
Are you using the Japanese operating system?
If possible, you can post a data file fragment for analysis
Echo Base64_encode (file_get_contents (' Your data file txt ', false, NULL, 0, 40));
Post the results



Open, it's all seen.

If you really want my help, then please do as I say.
It doesn't make any sense to put a picture.

Output Result:
b3jkzxitawqjb3jkzxitaxrlbs1pzalwdxjjagfzzs1kyxrlcxbheq==

About the system, Japanese, traditional, simplified is possible, but mainly Japanese system.

Excuse me, xuzuning General Base64_encode () are used in what place AH

Reconfirm, what is the operating system you are using? Be sure to answer

According to your description, pictures, data fragments
1, each time must first use Notepad to turn txt into utf-8, obviously the text is not utf-8 otherwise do not need to convert
2, the operating system is window series, otherwise there is no "notepad" to say
3, there is no BOM header in the data, that is, using the operating system default character set saved
4, from the picture, the Japanese part seems complete, did not observe the garbled phenomenon

Can be seen
If the operating system is Simplified Chinese, then the character set is GBK
If the operating system is traditional Chinese, then the character set is Big5
If the operating system is Japanese, then the character set is EUC or Shift-jis

So all you have to do is according to the character set of the operating system that you manipulate the data file to fill in the following statement
mysql_query ("Set names character set");
transcoding work will be done automatically by MySQL

Xuzuning greatly: Hello!

Answer: We downloaded from the Japan Amazon website, the operator's system is generally traditional and Japanese, if not to implement multi-system, then the Japanese system, we can ask the operator to use the Japanese system.

1. Notepad shows the ANSI encoding
2. Many of my visits to the Japanese site are SHIFT-JIS encoded


I would like to ask, if I use EUC or shift-jis, then we use the simplified or traditional display will not have a problem??

Many of the websites that visit Japanese are SHIFT-JIS encoded
Then the downloaded file is Shift-jis encoded, and the import database is also encoded with Shift-jis

Simplified or traditional is the concept of Chinese, not related to Japanese
When you manipulate simplified or traditional sources of data, is it naturally gbk or Big5?

are not all utf-8 in the final database?
No, it's the same.

Well, thank you xuzuning big, I try today!

It is our practice to convert download downloaded orders into Excel format before being read by PHP.

zy205817 Hello, you do this, and we use Notepad to Utf-8 are the same, we have to manually turn the code.

Xuzuning greatly, I would like to ask, PHP can be the txt file transcoding it? Just like we use Notepad to transcode???

Xuzuning greatly:
And the last time I did not garbled Japanese, this is my colleague to my TXT document, today I directly from the Japanese site download down, open the Japanese part is all garbled, need to use Excel transcoding, with Notepad directly to Uft-8 are not

  • 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.