Code page question

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
Rex, do you use either of these in TCC?
Code:
SetConsoleCP()
SetConsoleOutputCP()
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.
 

rconn

Administrator
Staff member
May 14, 2008
10,103
85
#2
vefatica wrote:

> Rex, do you use either of these in TCC?
>
> Code:
> ---------
> SetConsoleCP()
> SetConsoleOutputCP()
> ---------
> I suppose not since I couldn't locate them in TCC.EXE or TakeCmd.DLL.
Yes, TCC uses both (in SetCodePage()), but it is *only* called from CHCP.

The resource dll's also specify 1252 (but that's the Windows default
anyway).

Rex Conn
JP Software
 
#3
On Sat, 25 Apr 2009 20:32:46 -0500, rconn <> wrote:

|> Rex, do you use either of these in TCC?
|>
|> Code:
|> ---------
|> SetConsoleCP()
|> SetConsoleOutputCP()
|> ---------
|> I suppose not since I couldn't locate them in TCC.EXE or TakeCmd.DLL.
|---End Quote---
|Yes, TCC uses both (in SetCodePage()), but it is *only* called from CHCP.
|
|The resource dll's also specify 1252 (but that's the Windows default
|anyway).

Hmmm! They are not imported by any of the DLLs.

And you seem to be relying on the console sreen buffer using CP 437.

If I set HKCU\Console\CodePage to 1252 (and do no monkeying with CPs in any
plugins) LIST's banner line is corrupt; I see an accented "a" for the first two
characters, and the 166's which should be vertical bars around "F1 Help" appear
as a funny symbol that looks like a tiny underlined script "a").
--
- Vince