[fpc-pascal] Executing external processes and codepages

Michael Van Canneyt michael at freepascal.org
Wed May 11 11:35:18 CEST 2016



On Wed, 11 May 2016, Marco van de Voort wrote:

> In our previous episode, Jonas Maebe said:
>>>
>>> It assumes for windows utf16, and for Unix filesystem encoding (e.g.
>>> unix.pp:254).
>>>
>>> If you have more info, please share.
>>
>> The filesystem encoding is fine to find the binary on Unix, but the
>> parameters you specify to that binary will be interpreted by that same
>> binary once it's running. It will not interpret those parameters
>> according to the filesystem encoding, but according to whatever is
>> determined to be the DefaultSystemCodePage *by that executed binary*.
>
> I do understand that, and it will be fine most of the time.
>
> I'm not sure what you are suggesting as alternative. Saving the encoding at
> startup, so it can be reused in cases like this, in case somebody change
> defaultsystemcodepage?
>
> Or using defaultsystemcodepage instead of filesystem encoding?

Why not simply make the exec calls use RawByteString ?

It is then the responsability of the programmer. 
99,99% of cases it will get passed the correct system encoding, and if need
be the programmer can change it.

We should not fall in the trap of overengineering.

Michael.



More information about the fpc-pascal mailing list