Recent

Author Topic: On windows machine inserts in DB UTF8 correctly, on Ubuntu not  (Read 278 times)

daniel_sap

  • Full Member
  • ***
  • Posts: 115
On windows machine inserts in DB UTF8 correctly, on Ubuntu not
« on: January 04, 2026, 01:45:01 pm »
Hi,
I have issue with writing to database of UTF8 characters.
When I run the code on my windows dev machine everything is ok.
When the code is compiled and run on Ubuntu it writes data like this - Тест шеяш

Lazarus 4.2 (rev lazarus_4_2) FPC 3.2.2 x86_64-win64-win32/win64
mysql  Ver 8.0.41-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))

May be someone faced such an issue before.

I set this at the beginning of the program
Code: Pascal  [Select][+][-]
  1.  
  2. SetMultiByteConversionCodePage(CP_UTF8);
  3.  

Also
Code: Pascal  [Select][+][-]
  1. function TDBConnectionPool.CreateConnection: TSQLConnection;
  2. var
  3.   Con: TMySQL80Connection;
  4. begin
  5.   Con := TMySQL80Connection.Create(nil);
  6.  
  7.   Con.HostName := ConnectionDef.HostName;
  8.   Con.Port := ConnectionDef.Port;
  9.   Con.DatabaseName := ConnectionDef.DatabaseName;
  10.   Con.UserName := ConnectionDef.UserName;
  11.   Con.Password := ConnectionDef.Password;
  12.   Con.CharSet := ConnectionDef.CharSet; // This is 'utf8mb4';
  13.   Con.KeepConnection := True;
  14.   Con.Connected := True;
  15.  
  16.   Result := Con;
  17. end;
  18.  


 

TinyPortal © 2005-2018