TCC smashing Unicode quotes

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,221
78
Albuquerque, NM
prospero.unm.edu
What's going on here?
Code:
C:\>ver /r

TCC  22.00.40   Windows 7 [Version 6.1.7601]
TCC Build 40   Windows 7 Build 7601  Service Pack 1
Registered to COE-DDPTMHQ1

C:\>set test=%@char[0x201c]Test%@char[0x201d]

C:\>set test
"Test"

C:\>echo %@ascii[%test]
34 84 101 115 116 34

C:\>
At first, I thought this was a font issue, maybe the console using an OEM font. But no. It seems that TCC is replacing Unicode quotes with ASCII.
 
May 20, 2008
10,623
81
Syracuse, NY, USA
It gets even stranger.
Code:
v:\> set uq=%@char[0x201d]%@char[0x201c]

v:\> echo %@ascii[%uq]
8221 34

v:\> set uq=%@char[0x201c]%@char[0x201d]

v:\> echo %@ascii[%uq]
34 34
 
May 20, 2008
10,623
81
Syracuse, NY, USA
My console font, Andale Mono, supports both 0x201c (double left quotation mark) and 0x201d (double right quotation mark). With TCC, 0x201c does not display correctly, while 0x201d does display correctly.
1522800766940.png


Powershell gets them both right (in the same console as above).
1522800966794.png
 
May 20, 2008
10,623
81
Syracuse, NY, USA
WAD. TCC uses Unicode quotes to pass quoted arguments to tab completion functions.
This bit of code prints them correctly.
Code:
    WCHAR str[3] = L"\x201c\x201d";
    SetEnvironmentVariable(L"uq", str);
    GetEnvironmentVariable(L"uq", str, 3);
    Printf(L"%s\r\n", str);
This bit of code prints them incorrectly.
Code:
    WCHAR str[3] = L"\x201c\x201d";
    WCHAR cmd[32];
    Sprintf(cmd, L"set uq=%s", str);
    Command(cmd, 0);
    GetEnvironmentVariable(L"uq", str, 3);
    Printf(L"%s\r\n", str);

What does that have to do with arguments to tab completion functions? It seems more like SET is doing it.
 

rconn

Administrator
Staff member
May 14, 2008
11,926
133
What does that have to do with arguments to tab completion functions? It seems more like SET is doing it.
No, it is the code that parses the line into argv/argc format. SET doesn't have anything to do with it; internal commands do not parse quotes.

You can work around it with a SETDOS /X-7 before the SET.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,221
78
Albuquerque, NM
prospero.unm.edu
WAD. TCC uses Unicode quotes to pass quoted arguments to tab completion functions.

Why do you want to echo Unicode quotes?
ECHOing them would be purely cosmetic, of course. But I can't do other things either, like stashing them in environment variables. And note that the curly quotes, unlike the ASCII double-quote character, are valid (if weird) in filenames.