Re: [Lazarus] Unicode RTL

2023-07-25 Thread Mattias Gaertner via lazarus

On 24.07.23 21:49, Michael Van Canneyt via lazarus wrote:
[...]Hopefully, in the near future the compiler settings dialog in 
Lazarus will also allow you to specify a subtarget. 


I will add it.


Mattias

--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] Unicode RTL

2023-07-24 Thread Michael Van Canneyt via lazarus



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.
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Unicode RTL for FPC

2023-01-15 Thread Rolf Wetjen via lazarus

Hi Michael,

- update/clone fpc:
git clone https://gitlab.com/freepascal.org/fpc/source.git fpc
** ok

- Switch to unicode branch:
cd fpc **missing in the description
git switch unicodertl
** ok

- Create FPC unicode-rtl-capable compiler
cd fpc ** already in fpc
make all
** ok, beside of the fact that there's no make.exe (no bin) folder in 
the new fpc file tree. I used make.exe from lazarus fpc 3.2.2.


 - Create .fpc-unicodertl.cfg as per instructions in my first mail.
** There's no fpc.cfg in the new fpc file tree. In lazarus/fpc/3.2.2 
it's in fpc\3.2.2\bin\x86_64-win64.


Rolf
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Unicode RTL for FPC

2023-01-12 Thread Michael Van Canneyt via lazarus



On Thu, 12 Jan 2023, Rolf Wetjen via lazarus wrote:


Hi Michael,

I'm interested in this but I expect that I'm not the expert you are 
looking for. Some time ago ( Lazarus 1.8 or even earlier) I made a 
directory sync program for my own use for Windows which is aware of 
Unicode names in the file system.


Free Pascal is already aware of these names ? If you use UnicodeString, all
file system routines will use the native Windows unicode APIs.

You don't need the unicode RTL for that, however you will need to convert
the names to UTF8 for display in the lazarus GUI, as it uses UTF8.



I tried to follow your instruction but I failed as git is a pain for me:

 - Update your git clone
    git pull https://gitlab.com/freepascal.org/lazarus/lazarus.git 
lazarus. "lazarus" is my target folder.


- switch to branch unicodertl
    git branch --list gives only one branch: main

Can you please show in detail what to do?


Lazarus itself at this point has not been adapted. 
The instructions were meant for Free Pascal itself, not lazarus.


If you want nonetheless to try FPC:
- Create .fpc-unicodertl.cfg as per instructions in my first mail.

- update/clone fpc

git clone https://gitlab.com/freepascal.org/fpc/source.git fpc

- Switch to unicode branch:

git switch unicodertl

- Create FPC unicode-rtl-capable compiler

cd fpc
make all

- Optionally, install this compiler:

make install

- Use the compiler to create unicode rtl:

cd rtl

make clean all SUB_TARGET=unicodertl PP=/path/to/newly/compiled/compiler




Do you plan a full Unicode (up to four bytes per codepoint as far as I 
remember) or a DBCS (double byte character set) version? I don't know 
what Windows uses and what Delphi does.


I'm just leveraging the existing UnicodeString support of FPC, 
which mimics the Delphi/Windows support.


I'm not that much of a unicode expert, but as far as I understand it is UTF16, 
meaning that up to four bytes per codepoint can be used, which means that a full 
unicode codepoint can take up to 2 pascal characters: the pascal 'Char' can

never specify all unicode codepoints.

Michael.-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Unicode RTL for FPC

2023-01-12 Thread Rolf Wetjen via lazarus

Hi Michael,

I'm interested in this but I expect that I'm not the expert you are 
looking for. Some time ago ( Lazarus 1.8 or even earlier) I made a 
directory sync program for my own use for Windows which is aware of 
Unicode names in the file system.


I tried to follow your instruction but I failed as git is a pain for me:

 - Update your git clone
    git pull https://gitlab.com/freepascal.org/lazarus/lazarus.git 
lazarus. "lazarus" is my target folder.


- switch to branch unicodertl
    git branch --list gives only one branch: main

Can you please show in detail what to do?

Do you plan a full Unicode (up to four bytes per codepoint as far as I 
remember) or a DBCS (double byte character set) version? I don't know 
what Windows uses and what Delphi does.


Thank you,
Rolf
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] Unicode RTL for FPC

2023-01-06 Thread Michael Van Canneyt via lazarus



Hello,

I'm currently working for a company (Tixeo.com) that is preparing to use FPC to
recompile their flagship product (written in Delphi) for certain targets.

As part of this work, we're striving to make the Free Pascal 
RTL and Packages more compatible with recent Delphis.


That means:

- String = UnicodeString, Char=WideChar
- Dotted units.

Before you all get a heart attack:

Because backwards compatibility is important, FPC will of course 
continue to distribute a backwards-compatible RTL and packages, 
with single-byte string. All FPC modes will continue to function.


To make this possible a feature called 'subtargets' has been implemented.
This can be used for other things than the unicode RTL, but will be used for
the unicode RTL.

The RTL is compiled 'normally' and with subtarget=unicodertl; 
this will result in 2 separate sets of .o/.ppu files:


The normal CPU-OS directory and a CPU-OS-unicodertl directory.

The first part of the work has been pushed to gitlab in a branch called
unicodertl (NOT the svn/unicodertl branch):

- subtarget support is there
- The rtl compiles with make SUB_TARGET=unicodertl with the compiler as it
  is in that branch.

Needless to say, this is a major change that will need thorough testing.

The earlier testing starts, the better.

For those that wish to help in testing:

- Update your git clone

- switch to branch unicodertl.

- in the toplevel FPC directory, do a

make all

- if that went well, next to your fpc.cfg, create a file fpc-unicodertl.cfg  
with the following contents:


-dUNICODERTL
-Municodestrings


- to create a Unicode RTL, in the rtl directory do a

make clean all SUB_TARGET=unicodertl PP=path/to/the/new/compiler

- if that worked, you can try then a

make install SUB_TARGET=unicodertl

Note that this is NOT ready for production use:

- The packages have not yet been converted (working on this now) and will
  certainly fail...
- a private testsuite has been run and gives no failures, but the complete 
compiler testsuite still needs to be examined.
- Dotted names will be created after the unicode transition is deemed complete.

if you do wish to test and spot errors in the RTL or compiler, please file a 
bugreport.

You can use a tag 'UnicodeRTL' to report bugs for this.

Michael.
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus