Recent

Author Topic: MYSQL/ODBC Unreadable values  (Read 641 times)

Svaty

  • Newbie
  • Posts: 2
MYSQL/ODBC Unreadable values
« on: October 29, 2024, 05:01:25 pm »
Hi

Some time i try to find solution on problem with return values from mysql.

I have problem with ONLY TEXT,TINYTEXT,MEDIUMTEXT,.... These datatypes on culumns return wrong values(attached file from lazarus local variables). But there is no problem with another datatypes. Only solution what i found is CAST in mysql query.

Does somebody have another solution please??

MYSQL ODBC 8.3 unicode
MYSQL SERVER 8.4
Lazarus 3.0(3.2.2)



paweld

  • Hero Member
  • *****
  • Posts: 1361
Re: MYSQL/ODBC Unreadable values
« Reply #1 on: October 29, 2024, 06:39:26 pm »
The values are ok, only they are encoded in UTF16. You need to convert them to UTF8 using the UTF16ToUTF8 or UTF8Decode function from the LazUTF8 unit. ie.

Code: Pascal  [Select][+][-]
  1. uses
  2.   LazUTF8;  
  3.  
  4. var
  5.   s: String;
  6. begin
  7.   s := UTF16ToUTF8(dataset.Fields[0].Text);
  8.   //...
  9. end;
  10.  
Best regards / Pozdrawiam
paweld

 

TinyPortal © 2005-2018