Recent

Author Topic: converting with AnsiToUTF8 doesn't give the right string  (Read 759 times)

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
converting with AnsiToUTF8 doesn't give the right string
« on: February 26, 2020, 04:18:52 pm »
I'm changing my database from MySQL to Firebird 3.
In a table some names are put like this:
Quote
A.B. FRILLESÅS HANDELSTRÄDG.
The whole mysql database uses code latin1 for these characters.
Now I copy from a MySQL table to a FB table. I have to use AnsitoUTF8() to translate the extended characters otherwise Lazarus comes with an error : "malformed string". This is an error returned from Firebird. But it convert it to this:
Quote
A.B. FRILLES�S HANDELSTR�DG.
On the Firebird FAQ the solution to write it right is to put 'set names win1252;' at first in the isql.

But how when using Lazarus? AnsitoUTF8() converts the string, but not with the right characters.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: converting with AnsiToUTF8 doesn't give the right string
« Reply #1 on: February 26, 2020, 05:31:36 pm »
Maybe WinCPToUTF8 does what you need?
(Unit LazUtf8)

Bart

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: converting with AnsiToUTF8 doesn't give the right string
« Reply #2 on: February 27, 2020, 09:04:08 am »
thanks, Bart.

The right conversion.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

 

TinyPortal © 2005-2018