Sign in Join

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

Mailing lists / lazarus / 2017-07

FCL DOM [vs] laz2_DOM, and more

9 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Michael Van Canneyt
to Marcos Douglas B. Santos: Nowadays, we have full Unicode support in FPC. So, my question is: The units bellow is…
Marcos Douglas B. Santos wrote 12 lines
Hi, Nowadays, we have full Unicode support in FPC. So, my question is: The units bellow is still necessary to use XML with Lazarus or we can use just the original provided by FCL? laz2_DOM laz2_XMLRead laz2_XMLWrite laz2_XMLCfg laz2_XMLUtils laz_XMLStreaming

The FPC units use UnicodeString (UTF16), the lazarus units use UTF8. If the end result is used excluively in UTF8 strings, the lazarus version may be faster as there will be less conversions.

Michael.

Reply by email

Michalis Kamburelis
to Michael Van Canneyt

2017-07-30 10:00 GMT+02:00 Michael Van Canneyt via Lazarus :

Show quoted text 23 lines
On Sat, 29 Jul 2017, Marcos Douglas B. Santos via Lazarus wrote: > Hi, > > Nowadays, we have full Unicode support in FPC. > So, my question is: The units bellow is still necessary to use XML > with Lazarus or we can use just the original provided by FCL? > > laz2_DOM > laz2_XMLRead > laz2_XMLWrite > laz2_XMLCfg > laz2_XMLUtils > laz_XMLStreaming The FPC units use UnicodeString (UTF16), the lazarus units use UTF8. If the end result is used excluively in UTF8 strings, the lazarus version may be faster as there will be less conversions.

I wonder if we can move the UTF8-based XML units to FPC, to be available in the main FPC distribution too? (Possibly renamed like Utf8_XMLXxx or such, instead of LazX_XMLXxx.)

The reason I ask:

This requirement (wanting to have XML units based on AnsiStrings, not WideStrings, because your data is almost always in UTF8 and you're fine storing it in AnsiString ) is not really specific to Lazarus, or applications build on top of Lazarus. E.g. in Castle Game Engine I would prefer using UTF8-based XML units too, I often read UTF8 XML files (like X3D, Collada 3D models). But I don't want the "core" CGE to depend on LCL (this makes the process of building and testing simpler -- you can use CGE components in Lazarus, but you can also use CGE with our own minimalistic window management without Lazarus).

Regards,
Michalis

Reply by email

Michael Van Canneyt
to Michalis Kamburelis
Michalis Kamburelis wrote 41 lines
2017-07-30 10:00 GMT+02:00 Michael Van Canneyt via Lazarus : > > > On Sat, 29 Jul 2017, Marcos Douglas B. Santos via Lazarus wrote: > >> Hi, >> >> Nowadays, we have full Unicode support in FPC. >> So, my question is: The units bellow is still necessary to use XML >> with Lazarus or we can use just the original provided by FCL? >> >> laz2_DOM >> laz2_XMLRead >> laz2_XMLWrite >> laz2_XMLCfg >> laz2_XMLUtils >> laz_XMLStreaming > > > The FPC units use UnicodeString (UTF16), the lazarus units use UTF8. > If the end result is used excluively in UTF8 strings, the lazarus version > may be > faster as there will be less conversions. > I wonder if we can move the UTF8-based XML units to FPC, to be available in the main FPC distribution too? (Possibly renamed like Utf8_XMLXxx or such, instead of LazX_XMLXxx.) The reason I ask: This requirement (wanting to have XML units based on AnsiStrings, not WideStrings, because your data is almost always in UTF8 and you're fine storing it in AnsiString ) is not really specific to Lazarus, or applications build on top of Lazarus. E.g. in Castle Game Engine I would prefer using UTF8-based XML units too, I often read UTF8 XML files (like X3D, Collada 3D models). But I don't want the "core" CGE to depend on LCL (this makes the process of building and testing simpler -- you can use CGE components in Lazarus, but you can also use CGE with our own minimalistic window management without Lazarus).

That is up to the Lazarus people. If they are fine with that: no problem for FPC.

I do think that it probably uses some utility functions/units which then also need to be included in FPC. It also means there are 2 codebases.

An alternative approach would be to do what we do in other units as well, use 1 codebase for 2 kinds of strings:

unit dom;
Type
   DOMString = UnicodeString;
{$DEFINE USEUNICODESTRING}
{$i DOMh.inc}

and

unit domutf8;
Type
   DOMString = UTF8String;
{$DEFINE USEUTF8STRING}
{$i DOMh.inc}

etc.

Combined with some macro magic, I think this should be doable too.

Michael.

Reply by email

Juha Manninen
to Werner Pamler
Werner Pamler wrote
The Lazarus xml procedures are in package LazUtils which is a prerequisite for, but not part of, LCL. So, you can use these procedures without adding a requirement for LCL, LazUtils is sufficient.

Exactly. The earlier Lazarus Unicode support was specific to LCL which apparently still creates confusion.
Now you can use LazUtils for a Lazarus project, or just copy 1 or 2 needed unit files from it to a non-Lazarus project.

Juha

Reply by email