In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following is about the operations related to the GBK character set and UTF8 character encoding in MySQL. The secret of the text is that it is close to the topic. So, no gossip, let's go straight to the following, I believe you will benefit from reading this article on the operation of GBK character set and UTF8 character coding in MySQL.
How GBK and UTF8 are actually stored in the system:
1 、 GBK:
> SELECT hex (convert ('Hello' using gbk))
+-+
| | hex (convert ('Hello' using gbk)) |
|-- |
| | C4E3BAC3 |
+-+
The GBK character set is divided according to four lengths, so the corresponding relationship is obtained:
You-- > C4E3
Okay-- > BAC3
2 、 UTF-8:
> SELECT hex (convert ('Hello' using utf8))
+-+
| | hex (convert ('Hello' using utf8)) |
|-- |
| | E4BDA0E5A5BD |
+-+
The UTF8 character set is divided into six lengths, so the corresponding relationship is obtained:
You-- > E4BDA0
Okay-- > E5A5BD
So we can find something different. If we use the "hello" stored in UTF-8 (the corresponding underlying storage is: E4BDA0E5A5BD), but use GBK to read, GBK will split the E4BDA0E5A5BD according to every 4 bit length, and finally split it into E4BDA0E5A5BD.
(below)
> SELECT CONVERT (unhex ('E4BDA0E5A5BD') USING GBK)
+-- +
| | CONVERT (unhex ('E4BDA0E5A5BD') USING GBK) | |
+-- +
| | raccoon garbage |-- > it will become garbled if it is read by GBK. |
+-- +
> SELECT hex (convert ('racon' using gbk))
+-+
| | hex (convert ('racon' using gbk)) | |
+-+
| | E4BD |
+-+
> SELECT hex (convert ('clients' using gbk))
+-+
| | hex (convert ('using gbk')) | |
+-+
| | A0E5 |
+-+
> SELECT hex (convert ('clients' using gbk))
+-+
| | hex (convert ('using gbk')) | |
+-+
| | A5BD |
+-+
In addition, the hexadecimal code is inversely deduced to UTF8-encoded Chinese characters:
> SELECT CONVERT (unhex ('E4BDA0E5A5BD') USING utf8)
+-- +
| | CONVERT (unhex ('E4BDA0E5A5BD') USING utf8) | |
+-- +
| | Hello |
+-- +
> SELECT CONVERT (unhex ('E4BDA0E5A5BD') USING GBK)
+-- +
| | CONVERT (unhex ('E4BDA0E5A5BD') USING GBK) | |
+-- +
| | raccoon garbage |-- > it will become garbled if it is read by GBK. |
+-- +
Is there anything you don't understand about the operations related to the GBK character set and UTF8 character encoding in the above MySQL? Or if you want to know more about it, you can continue to follow our industry information section.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.