MysqlGBK encoding is equivalent to Chinese or Spanish characters, so the total number of characters is 2selectchar_length (character). One Chinese Character occupies 2 bytes, therefore, the total length of the byte is 4 selectlength (character); 1 English character occupies 1 byte, so the total length of the byte is 5 selectlength (china); 1 Chinese Character occupies 2 bytes, 1
Mysql GBK encoding is equivalent to Chinese or Spanish characters, so the total number of characters is 2 select char_length (character); 1 Chinese Character occupies 2 bytes, therefore, the total byte length is 4 select length (characters); 1 English character occupies 1 byte, so the total byte length is 5 select length (china); 1 Chinese Character occupies 2 bytes, 1
Mysql
-GBK encoding --
-Both Chinese and Spanish characters are treated equally, so the total number of characters is 2.
Select char_length ('characters ');
-One Chinese Character occupies 2 bytes, so the total length of the byte is 4.
Select length ('characters ');
-One English character occupies 1 byte, so the total length of the byte is 5.
Select length ('China ');
-One Chinese Character occupies 2 bytes, and one byte occupies 8 digits, so the total bit length is 32
Select bit_length ('characters ');
-- UTF-8 coding --
-Both Chinese and Spanish characters are treated equally, so the total number of characters is 2.
Select char_length ('characters ');
-One Chinese Character occupies three bytes, so the total length of the byte is 6.
Select length ('characters ');
-One English character occupies 1 byte, so the total length of the byte is 5.
Select length ('China ');
-One Chinese Character occupies 3 bytes, and one byte occupies 8 digits, so the total bit length is 48.
Select bit_length ('characters ');
Original article address: mysql String length functions char_length, length, bit_length difference, thank you for sharing.