[fpc-pascal] string to widestring : what are the difficulties ?

Michael Van Canneyt michael at freepascal.org
Sun Oct 9 13:16:21 CEST 2016



On Sun, 9 Oct 2016, Jonas Maebe wrote:

> On 09/10/16 08:50, Sven Barth wrote:
>> Am 08.10.2016 22:48 schrieb "Ched"
>> <charles.edouard.des.vastes.vignes at gmail.com
>> <mailto:charles.edouard.des.vastes.vignes at gmail.com>>:
>>> In http://www.freepascal.org/docs-html/ref/refsu14.html#x37-400003.2.8
>>> , the stack sized used by a Shortstring is Declared length + 2 . Why not
>>> Declared length + 1 ?
>> 
>> 1 Byte length and a zero byte to allow easy conversion to PChar.
>
> That is incorrect. Shortstring stringconstants are stored like that in the 
> constant data section so they can be used both for assigning to shortstrings 
> and to pchars, but shortstring variables/fields themselves are never 
> null-terminated by the compiler/RTL.
>
> So there is in fact an error in the documentation: it should be length + 1.

That has already been corrected.

Michael.



More information about the fpc-pascal mailing list