1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Code page question

Discussion in 'Plugins' started by vefatica, Apr 25, 2009.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    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.
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,726
    Likes Received:
    80
    vefatica wrote:

    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. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    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
     

Share This Page