[fpc-pascal] Unicodestrings and Assign(File)

Marco van de Voort marcov at stack.nl
Sat May 19 17:36:08 CEST 2012

In our previous episode, Sven Barth said:
> While I can not comment on the changes you listed (though they sound 
> more or less valid) 

I'm not sure if the *rec records can handle pointers, one probably can't use
reference types in them, because the standard filedescriptions are

Think what happens if those are simply "cloned".

> I can comment on those you didn't list: If you 
> change do_open to support Unicode you should do this for the other 
> functions (e.g. write, read) as well so that only the *W functions are 
> used for them. Also you need to keep in mind that do_open is used by 
> platform independant code so you would need to change the 
> declarations/handling for all other platforms as well. Also you need to 
> change the declaration of Assign as this expects a Short-/AnsiString.

> Also I don't know whether the Unix users would be happy if we'd push 
> UnicodeString upon them or whether they'd prefer AnsiString(CP_UTF8).

Probably they will be rawbytestring, so both can be passed to it, and the
per platform code must then change it to whatever encoding (ansi,utf8,utf16)
the API expects.
> In the end maybe it should be AnsiString(CP_UTF8) for Unix systems and 
> UnicodeString for Windows systems and AnsiString(CP_SCP) (the current 
> string) for the other systems, so especially the platform independant 
> code needs to be adjusted to support all three cases without problems 
> (which might not need that much work in the end...).

I'm not sure that is true even without the above remark.

I would say for *nix it just remains "ansistring", the default 1-byte
encoding. This fixes the case where e.g. embedded Linux doesn't expect utf8,
which could otherwise have undesirable effects.

Note that the default encoding can be the same as utf8. (and probably will
be on desktop unix)

> I hope other core developers comment on this as well, as I'm not so firm 
> regarding the consequences of such changes...

There are some interesting discussions on various lists you might want to
read.... :-)

More information about the fpc-pascal mailing list