[fpc-pascal] Unicodestrings and Assign(File)

Sven Barth pascaldragon at googlemail.com
Sat May 19 18:29:13 CEST 2012

On 19.05.2012 17:47, J├╝rgen Hestermann wrote:
>  > 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.
> Yes. It can be a can of worms. ;-)
> Although, as said: Only very few functions realy act on the file name.
> Most use the file handle only (which will not change).

Regarding the filename, yes, but while we're at it we could also change 
functions like WriteFile to WriteFileW (etc.)...

>  > 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).
> Yes, this is a general question:
> What kind of string type should be used within Free Pascal mainly?
> I am not sure how this is all affected by
> http://wiki.freepascal.org/FPC_Unicode_support#Roadmap_of_RTL_Unicode_support_with_UnicodeString

I don't know how up to date and valid that page is... the latest changes 
in 2012 were only cosmetically and the ones before that were in 2009 way 
before the merge of cpstrnew.

>  > 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...).
> As far as I know currently all platforms share the same filerec/textrec
> definitions (which is
> an array of bytes now). If that is changed then it would be changed for
> all platforms.
> But it can be changed to generic string type too. I am not so sure what
> this actually
> means when the type differs from one platform to the other. For example,
> I have to use a "pointer
> to widestring" for CreateFileW for Windows. So I need to convert to a
> null terminated widestring
> from the existing string type and this conversion must work under all
> circumstances.

Well... you can define a "RTLString" type which is an alias to another 
string type depending on the platform and which is then used in the 
records. Or, as Marco suggested, we use RawByteString for this.


More information about the fpc-pascal mailing list