Recent

Author Topic: Lazarus in non-UTF8 mode (-dDisableUTF8RTL): does anyone still use this?  (Read 3248 times)

Bart

  • Hero Member
  • *****
  • Posts: 5516
    • Bart en Mariska's Webstek
Re: Lazarus in non-UTF8 mode (-dDisableUTF8RTL): does anyone still use this?
« Reply #15 on: February 04, 2025, 06:43:24 pm »
The catch is that there are not only our software accessing the ElevateDB. We write data into Elevate and another software do further processing. This software is Delphi based.  We must make it work that the Delphi Software see the right information, so we can not see it independently with a solution. The manufacturer says that Delphi is his main sales for the Desktop and Server Edition and Free Pascal is only a small part. To small for additional work to increase compatibility.

Delphi nowadays is UTF16.
The fact that problems arise suggests that inside the database strings are stored as 1 byte ANSI strings.
As long as you store the strings in the correct encoding, for all the rest of the code, you can used default Lazarus setting where string is UTF8.

Besides that.
The fact that currently you rely on this -dDisableUTF8RTL define is exactly the reason why we ask.
We don't want to rush into changing something like that without knowing the consequences.
So, thanks for your feedback.

In the long run though, you might have to change the way your program stores/reads string data from said database.

Bart

Thaddy

  • Hero Member
  • *****
  • Posts: 16580
  • Kallstadt seems a good place to evict Trump to.
Re: Lazarus in non-UTF8 mode (-dDisableUTF8RTL): does anyone still use this?
« Reply #16 on: February 04, 2025, 06:47:03 pm »
The fact that problems arise suggests that inside the database strings are stored as 1 byte ANSI strings.
As long as you store the strings in the correct encoding, for all the rest of the code, you can used default Lazarus
Yes, thank you Bart - not -
The size of my fields just quadrupled.....
And you think that is not a problem? Ansi + code page is one byte. Any unicode takes 4 byte for storage. (yes, that is 8,16 and 32)

Silly.

Thaddy

p.s. I know with current hardware that should not matter, but it does.
It also destroys backward compatibility for those that do not follow my advice and keep insisting on "string"...
Anyway, I am aware of that problem and can work around it, but this example shows it is too early to drop it.
Actually, this morning I agreed, this afternoon I am against.
« Last Edit: February 04, 2025, 06:54:12 pm by Thaddy »
But I am sure they don't want the Trumps back...

Bart

  • Hero Member
  • *****
  • Posts: 5516
    • Bart en Mariska's Webstek
Re: Lazarus in non-UTF8 mode (-dDisableUTF8RTL): does anyone still use this?
« Reply #17 on: February 04, 2025, 07:03:16 pm »
If you insist on using old ANSI 1-byte strings in your database, then I sincerely hope that at least all of them use the same codepage, and that you know which codepage that is.
At that point you can do something like:
Code: Pascal  [Select][+][-]
  1. type
  2.   DataString = AnsiString(CP_Whatever);
and use that type for interaction with the database.
If you assing String to DataString and vice versa, automatic conversion should take place, or you can manually take care of that: MyDataString := UTF8ToCPWhatever(AnyStringOfTypeString) (from LConvEncoding unit, or similar from Alexey's derived similar unit).

As long as you store in the correct codepage (and read and convert from the correct codepage), at least in theory you should not be bothered by the fact that Lazarus defaults to using UTF8 for encoding it's strings.

Disclaimer: I have next to no experience with databases.

Bart

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12050
  • FPC developer.
Re: Lazarus in non-UTF8 mode (-dDisableUTF8RTL): does anyone still use this?
« Reply #18 on: February 04, 2025, 09:21:40 pm »
Delphi nowadays is UTF16.

But if you communicate with 8-bit APIs, or want to store in 8-bit units, you have to pay attention.


PascalDragon

  • Hero Member
  • *****
  • Posts: 5870
  • Compiler Developer
Re: Lazarus in non-UTF8 mode (-dDisableUTF8RTL): does anyone still use this?
« Reply #19 on: February 04, 2025, 10:30:07 pm »
Solution from the manufacturer is to use -dDisableUTF8RTL or switching to Delphi.
Maybe switch to the new FPC Unicode mode may be a good option.

It is not yet clear for which platforms we'll distribute which RTL. So it would be best for teco to investigate how to correctly adjust their software.

Simply try {$mode delphiunicode} on the units where code is affected.

Please do not suggest mode DelphiUnicode as it's essentially a hack as the remaining RTL still stays with String = AnsiString thus leading to subtle problems. Consider it deprecated. In main this will be replaced by the whole RTL either being String = AnsiString or String = UnicodeString.

 

TinyPortal © 2005-2018