Recent

Author Topic: [solved] MySQL table field defined as Char(1)  (Read 2015 times)

Zvoni

  • Hero Member
  • *****
  • Posts: 2300
Re: MySQL table field defined as Char(1)
« Reply #15 on: May 05, 2022, 03:06:27 pm »
I put "utf8" in my connection it did not work, but with "utf8mb4" now it works.
I will explore to learn what is the difference between these 2 encoding mode.

 Thanks a lot.
utf8 can store up to 3 byte character
utf8mb4 can store up to 4 byte characters

--> utf8 is a subset of utf8mb4

The question is: Do you need utf8mb4?

and check the charset in your my.ini/my.cnf
they should be equal
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

jcmontherock

  • Full Member
  • ***
  • Posts: 234
Re: MySQL table field defined as Char(1)
« Reply #16 on: May 05, 2022, 03:18:41 pm »
The strange thing is that the table was created with utf8, but it seems that with mysql 8 the default encoding is utf8mb4, even if you set utf8 at table creation, so one char takes max. 4 bytes instead 3 in utf8.
see: https://dev.mysql.com/blog-archive/mysql-8-0-when-to-use-utf8mb3-over-utf8mb4/
« Last Edit: May 05, 2022, 03:24:50 pm by jcmontherock »
Windows 11 UTF8-64 - Lazarus 3.2-64 - FPC 3.2.2

Zvoni

  • Hero Member
  • *****
  • Posts: 2300
Re: MySQL table field defined as Char(1)
« Reply #17 on: May 05, 2022, 03:46:36 pm »
The strange thing is that the table was created with utf8, but it seems that with mysql 8 the default encoding is utf8mb4, even if you set utf8 at table creation, so one char takes max. 4 bytes instead 3 in utf8.
see: https://dev.mysql.com/blog-archive/mysql-8-0-when-to-use-utf8mb3-over-utf8mb4/
That's why i said to check your my.ini/my.cnf
AFAIK, the charset can be set there, too.
See: https://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf-8-in-my-cnf
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018