[fpc-pascal] Executing external processes and codepages

Jonas Maebe jonas.maebe at elis.ugent.be
Wed May 11 12:09:02 CEST 2016


Michael Van Canneyt wrote on Wed, 11 May 2016:

> On Wed, 11 May 2016, Marco van de Voort wrote:
>
>> I don't like that. The 3.x idea is to get rid of manual conversions and
>> hack-and-convert-it-as-you-go encoding management, not just rebadge the old
>> practices to rawbytestring.
>
> You may not like it, but there is simply no other choice:
>
> Since you don't know what the receiving program does with the receives
> arguments, all attempts to guess it are erroneous by definition.

It will either interpret them according to the code page specified by  
the environment, or not perform any interpretation at all. In both  
cases, converting the arguments to the code page of the environment is  
the right thing to do.

> Only the programmer knows what the receiving program will do (or  
> should), so he must take it into account. Hence rawbytestring.

If it is an FPC program, then if it is compiled with FPC 2.6.x it will  
not reinterpret the command line arguments at all, while when compiled  
with FPC 3.x it will reinterpret the command line arguments. The  
caller of such a program should not have to worry with which version  
of FPC it has been compiled.

> Don't pamper the programmer so much. He needs to make correct decisions.

They have to correctly set or specify the environment for the program  
they are executing when they want to force a specific encoding for its  
command line arguments.


Jonas



More information about the fpc-pascal mailing list