- May
- 13,547
- 197
Rex, do you use either of these in TCC?
I suppose not since I couldn't locate them in TCC.EXE or TakeCmd.DLL.
At least one nice thing happens when I use them to set the console CP to the ANSI CP. Apparently by default, here, the console's CP is 437 while the ANSI CP is 1252. In this case, after "ECHO %@CHAR[27]" and reading that character from the screen buffer with a plugin (%_CURCHAR, using ReadConsoleOutputCharacterW and writing that Unicode character to pszArgs), %@ASCII[%_CURCHAR] is 8592.
If, during plugin init, I SetConsoleCP(1252) and SetConsoleOutputCP(1252) (matching the locale's ANSI CP here) then it seems everyone "is on the same page", at least as far as that little test above is concerned (%@ASCII[%_CURCHAR]] == 27) which is nice if you want to match characters screped from the buffer to familiar numeric codes. Of course there may be a big down-side too.
As far as I have been able to determine, the console (the actual CSRSS mechanism) uses OEMCP by default but console processes, by default, get the default ANSI CP ... almost guaranteeing a mismatch(?).
I (perhaps obviously) don't get all the ins/outs of code pages, so any comments will be appreciated.
Thanks.
Code:
SetConsoleCP()
SetConsoleOutputCP()
At least one nice thing happens when I use them to set the console CP to the ANSI CP. Apparently by default, here, the console's CP is 437 while the ANSI CP is 1252. In this case, after "ECHO %@CHAR[27]" and reading that character from the screen buffer with a plugin (%_CURCHAR, using ReadConsoleOutputCharacterW and writing that Unicode character to pszArgs), %@ASCII[%_CURCHAR] is 8592.
If, during plugin init, I SetConsoleCP(1252) and SetConsoleOutputCP(1252) (matching the locale's ANSI CP here) then it seems everyone "is on the same page", at least as far as that little test above is concerned (%@ASCII[%_CURCHAR]] == 27) which is nice if you want to match characters screped from the buffer to familiar numeric codes. Of course there may be a big down-side too.
As far as I have been able to determine, the console (the actual CSRSS mechanism) uses OEMCP by default but console processes, by default, get the default ANSI CP ... almost guaranteeing a mismatch(?).
I (perhaps obviously) don't get all the ins/outs of code pages, so any comments will be appreciated.
Thanks.