[fpc-pascal] Strings - suggestions

Michael Van Canneyt michael at freepascal.org
Sat Dec 22 14:21:36 CET 2012



On Sat, 22 Dec 2012, dev.dliw at gmail.com wrote:

> Hi,
> thx, got it...
>
>> There will always be conversion if
>> 1) a unit specifies a string type by itself.
>> 2) the unit comes in compiled form.
>
> One more question:
> If a particular unit (maybe 3rd party) does not define its string type, what
> string type is used:
> (a) the type defined in project,
> (b) a fpc default type?

That depends. See below.

> In other words, can I force *all* sources in my project to use the same string
> type, provided that I know, they don't do direct access?

Yes, *if* the units are recompiled.

> The wiki says [http://wiki.freepascal.org/FPC_Unicode_support], that
> - shortstring
> - ansistring
> - widestring
> - utf8string
> - utf16string
> - utf32string
> - ucs2string (?)
> - ucs4string (?)
> may be supported.

They will just be pre-defined string types.

> So in future I will be able to define any of these for my source (and switch
> between them), without changing code?
> Thus:
> Any function with "string" as param will be "automatically" overloaded for all
> supported string types?

Provided 
a) you recompile everything
b) The unit does not specify a string type
the answer seems "yes".

Michael.



More information about the fpc-pascal mailing list