RemedyBG»Forums
1 posts
Problem with Unicode command-line arguments on Windows
Edited by bzzr on
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
2444 posts / 2 projects
Problem with Unicode command-line arguments on Windows
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.
265 posts / 1 project
None
Problem with Unicode command-line arguments on Windows
I'll look into it. Thanks guys.