[Lazarus] FCL DOM [vs] laz2_DOM, and more

Michael Van Canneyt michael at freepascal.org
Sun Jul 30 11:01:57 CEST 2017



On Sun, 30 Jul 2017, Michalis Kamburelis via Lazarus wrote:

> 2017-07-30 10:00 GMT+02:00 Michael Van Canneyt via Lazarus
> <lazarus at lists.lazarus-ide.org>:
>>
>>
>> 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.


More information about the Lazarus mailing list