Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2023-07

Unicode RTL

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hello,

I have just completed phase one of the "Unicode RTL" effort.

The 'Unicode RTL' is an effort to be more Delphi compatible:
- Char = Unicode Char and String = UnicodeString
- Provide dotted filenames.
Basically closer to the RTL as it exists in more recent versions of Delphi (essentially post - Delphi 2009)

This RTL will co-exist with the current RTL (single-byte char, no dotted names), but will share the same codebase.

More explanations can be found here:

https://wiki.freepascal.org/FPC_Unicode_RTL

This coexistence of 2 RTLs is accomplished with 'Subtarget support'.

Subtarget support is a means to consistently apply a set of Free Pascal compiler settings to everything that you compile.

Subtarget support is explained in more detail here: https://wiki.freepascal.org/FPC_Subtarget_Support

While it is now used to create a unicode rtl, it could also be used to

* create a llvm-compiled RTL.
* create an rtl with debug info and one without.
* compile the various Lazarus widgetsets into different directories
* ... any other things you may think of ...

all with a single installation of FPC.

For the second part of the effort, 'provide dotted filenames', the actual work is finished, but still needs merging to trunk.

This second part is expected to be merged in the next days/weeks.

But today, using FPC trunk, you can now recompile the Free Pascal RTL, Packages and Utils (but not the compiler itself!) into a set of units where

Char = UnicodeChar
String = UnicodeString

To compile (and install) the unicode rtl, all you need to do is follow the steps outlined in

https://wiki.freepascal.org/FPC_Unicode_RTL

Basically, this means creating a 2-line configuration file for the unicodertl subtarget, and compiling the RTL, packages and utils with

make SUB_TARGET=unicodertl

For those that need/want more delphi-compatible code, I would love to hear of your experience with the unicode rtl. I have done extensive testing, but as practice shows, there will always be cases which defy ordinary test cases...

If the 2 wiki pages need more explanations, please let me know and I will do my best to improve the explanations.

Hopefully, in the near future the compiler settings dialog in Lazarus will also allow you to specify a subtarget.

Michael.

Reply by email

Kirinn
to Michael Van Canneyt

Hi,

A "unicode" RTL is of course great for targeting legacy Windows platforms, but for those of us on Linux, UTF-8 is the way. To this end, it would be helpful to add a paragraph on the wiki page underlining how to retain the single-byte RTL; or, if no user action is necessary, mention that, to set you for this hard work!

~Kirinn

On Mon, 24 Jul 2023 21:49:39 +0200 (CEST)

Michael Van Canneyt wrote 70 lines
Hello, I have just completed phase one of the "Unicode RTL" effort. The 'Unicode RTL' is an effort to be more Delphi compatible: - Char = Unicode Char and String = UnicodeString - Provide dotted filenames. Basically closer to the RTL as it exists in more recent versions of Delphi (essentially post - Delphi 2009) This RTL will co-exist with the current RTL (single-byte char, no dotted names), but will share the same codebase. More explanations can be found here: https://wiki.freepascal.org/FPC_Unicode_RTL This coexistence of 2 RTLs is accomplished with 'Subtarget support'. Subtarget support is a means to consistently apply a set of Free Pascal compiler settings to everything that you compile. Subtarget support is explained in more detail here: https://wiki.freepascal.org/FPC_Subtarget_Support While it is now used to create a unicode rtl, it could also be used to * create a llvm-compiled RTL. * create an rtl with debug info and one without. * compile the various Lazarus widgetsets into different directories * ... any other things you may think of ... all with a single installation of FPC. For the second part of the effort, 'provide dotted filenames', the actual work is finished, but still needs merging to trunk. This second part is expected to be merged in the next days/weeks. But today, using FPC trunk, you can now recompile the Free Pascal RTL, Packages and Utils (but not the compiler itself!) into a set of units where Char = UnicodeChar String = UnicodeString To compile (and install) the unicode rtl, all you need to do is follow the steps outlined in https://wiki.freepascal.org/FPC_Unicode_RTL Basically, this means creating a 2-line configuration file for the unicodertl subtarget, and compiling the RTL, packages and utils with make SUB_TARGET=unicodertl For those that need/want more delphi-compatible code, I would love to hear of your experience with the unicode rtl. I have done extensive testing, but as practice shows, there will always be cases which defy ordinary test cases... If the 2 wiki pages need more explanations, please let me know and I will do my best to improve the explanations. Hopefully, in the near future the compiler settings dialog in Lazarus will also allow you to specify a subtarget. Michael. _______________________________________________ fpc-devel maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Michael Van Canneyt
to Kirinn
Kirinn wrote
Hi, A "unicode" RTL is of course great for targeting legacy Windows platforms, but for those of us on Linux, UTF-8 is the way.

It is not only for legacy windows platforms.
The target platform is secondary.

What to use depends more on your codebase than on your target platform. There is a lot of Delphi code out there that assumes that string=unicodestring.

If, like my current company, you have a large Delphi application that you wish to run on linux, then you may be better off with a unicode RTL.

To this end, it would be helpful to add a paragraph on the wiki page underlining how to retain the single-byte RTL; or, if no user action is necessary, mention that, to set you for this hard work!

No user action is necessary.

But your advice is good: I have added this to the page, and made clear that the RTL as it currently exists, is still the default RTL.

Michael.

Reply by email

Mattias Gaertner
to Michael Van Canneyt: I have just completed phase one of the "Unicode RTL" effort. The 'Unicode RTL' is an…
Michael Van Canneyt wrote 8 lines
[...] Subtarget support is explained in more detail here: https://wiki.freepascal.org/FPC_Subtarget_Support * compile the various Lazarus widgetsets into different directories * ... any other things you may think of ... all with a single installation of FPC.

The -t switch alters the $fpctarget, and therefore searches the fpc units in another directory. So a non-fpc project must add the -Fu for the fpc units itself.

Can you elaborate, how -t gives non-fpc projects new possibilities?

Mattias

Reply by email

Michael Van Canneyt
to Mattias Gaertner
Mattias Gaertner wrote 13 lines
On 24.07.23 21:49, Michael Van Canneyt via fpc-devel wrote: > [...] > Subtarget support is explained in more detail here: > https://wiki.freepascal.org/FPC_Subtarget_Support > * compile the various Lazarus widgetsets into different directories > * ... any other things you may think of ... > > all with a single installation of FPC. The -t switch alters the $fpctarget, and therefore searches the fpc units in another directory. So a non-fpc project must add the -Fu for the fpc units itself.

How can a project be non-fpc ? Every project is compiled with fpc ?

If I understand your question correct:

If you don't wish to honor the subtarget in non-fpc sources, you don't need to do anything, as long as you don't use the $fpctarget in your own -Fu/-FU.

It will then simply use the FPC units for the specified subtarget.

If you wish to 'honor' the subtarget in your own output paths, you must add $fpctarget in -FU (and subsequently to -Fu) for your own compiler settings.

Can you elaborate, how -t gives non-fpc projects new possibilities?

I think of it as "fpc-global build modes".

(build modes as implemented by lazarus may do some additional tricks, obviously)

It is of course mainly geared towards being able to have different unit trees in the fpc distribution.

But it is a new concept, and time will have to tell what uses can be made of it outside the fpc distribution itself. It can be that the answer is 'none'.

Maybe some small adaptations are needed to make it more useful. "Time will tell" also applies here, I suppose.

Michael.

Reply by email

Michael Van Canneyt
to Adriaan van Os
Adriaan van Os wrote 8 lines
Michael Van Canneyt via fpc-devel wrote: > > Hello, > > I have just completed phase one of the "Unicode RTL" effort. I object to the name "Unicode" RTL. Where people talk about what they call "Unicode" they usually mean UCS-16 or UTF-16 or UTF-16-mishandled-as-UCS16.

Objection duly noted.

Michael.

Reply by email