[Lazarus] Making sources compatible with Delphi (but Lazarus is priority)

Mattias Gaertner nc-gaertnma at netcologne.de
Wed May 3 14:37:00 CEST 2017


On Wed, 3 May 2017 15:15:53 +0300
Juha Manninen via Lazarus <lazarus at lists.lazarus-ide.org> wrote:

>[...]
> > Back in Lazarus compiling such a file gives the error:
> > LazUnicodeTest.lpr(28,10) Error: UTF-8 code greater than 65535 found  
> 
> Äh, I did not test moving it back to Lazarus.

Well, that's the point of sharing code, isn't it?


> Hmmm... why does FPC not understand the BOM?

It does. And so does Delphi. But with and without BOM have different
meanings.

 
> > You are right, that using Unicode with Lazarus only needs a couple of
> > rules to follow. Sharing code with Delphi adds a few more rules.  
> 
> One valid choice is to edit in Lazarus and copy to Delphi only to be
> built. I understood Marcos Douglas planned something like that.
> If code really must be edited in both, how to solve it?

That's what I tried to explain to Marcos and what you described as
"That must be very confusing."


> This was another complication I did not think about. :(
> 
> About the couple of rules to follow, I had these in mind:
>  1. Normally use type "String".
>  2. Assign a constant always to a type String variable.
>  3. Use type UnicodeString explicitly for API calls that need it.

4. When sharing code with Delphi use BOM or use only ASCII constants.
You can choose for each unit. Either way load texts using
resourcestring or similar techniques.

5. What about Char and aString[]?
6. What about PChar?

 
> They are not listed as a short list in wiki. The wiki page is more detailed.
> Maybe they should be listed as a "Getting started" paragraph.

Good idea.

Mattias


More information about the Lazarus mailing list