Register
RemedyBG»Forums»Problem with Unicode command-line arguments on Windows
1 posts
Problem with Unicode command-line arguments on Windows
3 weeks, 3 days ago Edited by bzzr on Jan. 4, 2020, 8:05 p.m.
While using Remedy I noticed that the strings given as arguments in the "Command Arguments" field of the Session menu were incorrectly encoded. Running the program normally seems to give properly encoded arguments, so I'm thinking this may be a bug. Here's the code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <stdio.h>

int wmain(int argc, wchar_t **argv, wchar_t **envp)
{
    for (int i = 0; i < argc; i++)
    {
        wprintf(L"Argument %d: ", i);

        wchar_t *arg = argv[i];
        while (*arg)
        {
            wprintf(L"%x ", *arg);
            arg++;
        }
        wprintf(L"\n");
    }
}


Running the program like this

program.exe Pão


outputs this

...
Argument 1: 50 e3 6f


That's encoded correctly. But running the program through Remedy outputs this

...
Argument 1: 50 c3 a3 6f


Am I missing something or is this really a bug?
Mārtiņš Možeiko
1998 posts / 1 project
Problem with Unicode command-line arguments on Windows
3 weeks, 3 days ago
0xc3 0xa3 in utf-8 is 0xe3. Seems that Remedy is passing unicode encoded in utf-8 which is not really what wide chars means on Windows. So this seems to be a bug with Remedy, not an issue with your code.
153 posts / 1 project

None

Problem with Unicode command-line arguments on Windows
3 weeks, 2 days ago
I'll look into it. Thanks guys.