On 2021-12-09 10:28, Marius Amado-Alves wrote:
Yeah, it's probably the quotation marks. I found no way around it with GNAT.OS_Lib. The quotes are needed because the names have spaces.
Only way I found that works is with the command inside a .BAT file, then call that with GNAT.OS_Lib.Spawn
Arguments : Argument_List :=
( 1=> new String'("C:\Test\save_as_txt.bat"),
2=> new String'("")
);
begin
Spawn
( Program_Name => "C:\Test\save_as_txt.bat",
Args => Arguments,
Output_File_Descriptor => Standout,
Return_Code => Result
);
Also the BAT file *must* start with the magic incantation
chcp 65001
on the first line, in order for the accented characters to work.
Try to put arguments with spaces in quotation marks. E.g.
3 => new String'("""a b c d""");
Another potential issue is with non-ASCII characters. I do not know what
call GNAT.OS_Lib uses internally. If that is CreateProcessA then you are
out of luck. If it calls to CreateProcessW then the question how
GNAT.OS_Lib converts arguments to UTF-16. There are two most likely possibilities:
1. The arguments are treated as Latin-1 encoded
2. The arguments are treated as UTF-8 encoded
In both cases (and always) never ever use anything but ASCII in the
source code. Do not trust the compiler, do not trust the file system, do
not trust GPS.
Encode your funny letters explicitly. Use Character'Val with the codes
you want (or Characters.Latin_1). First for Latin-1, then if that does
not work, try UTF-8.
P.S. Note that GLib solution consistently uses CreateProcessW and UTF-8
in the strings and never ever Latin-1.
P.P.S. You can just call CreateProcessW, it is not a big deal. Remember
to use Wide_String with UTF-16 encoded content. Windows is
little-endian, so use UTF-16LE.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)