[Lazarus] Converting all code to use UnicodeString
Juha Manninen
juha.manninen62 at gmail.com
Tue Sep 26 02:52:43 CEST 2017
On Tue, Sep 26, 2017 at 3:14 AM, Marcos Douglas B. Santos via Lazarus
<lazarus at lists.lazarus-ide.org> wrote:
> So, you mean that I cannot declare a constant without specify the
> type. The language allow me but it won't work?
Yes you can declare a string constant without specifying the type.
> 3.1. "When a parameter type is a pointer PWideChar,
> you need a temporary UnicodeString variable.
> ...
> That is a ugly hack. This code doesn't make any sense, if you don't
> know about these Unicode issues.
> We need do remember that trick when we are coding... not good.
It is not so ugly. It is actually an elegant solution. Just one
assignment, using the FPC's automatic conversion in a clever way. No
explicit conversion functions or anything.
The "ugly" pointer typecast is needed always, also in Delphi.
> 4. "Reading / writing text file with Windows codepage"
> ...
> The text said: "This is not compatible with Delphi ".
> Examples on that page are hacks.
The solution is to NOT use Windows codepages. They can be seen as a
historical remain with severe inherent problems which are solved by
Unicode already a long ago.
Windows has supported full Unicode since year 2000, and supported
UCS-2 before that.
Why would anybody still use the historical Windows codepages?
> Summary:
> I know that was a huge work for who made that. Lazarus is more
> Unicode, more compatible with Delphi, and the team could move on.
> Great.
> But you might agree with me that this is far from a good design, right?
IMO it is not far from a good design. From FPC's point of view it is a
hack but you can write 100% Delphi compatible code by following just
few simple rules (and dumping the historical Windows codepages).
Juha
More information about the Lazarus
mailing list