[WSH] How to properly run non English scripts in English Windows? RRS feed

  • Question

  • For example, below simple `test.vbs` code displays some Cyrillic characters, but was encoded using ANSI encoding with Cyrillic code page 1251.

    wscript.echo "БГДЖЗИЙ"

    The file's binary data:

    77 73 63 72 69 70 74 2E 65 63 68 6F 20 22
    C1 C3 C4 C6 C7 C8 C9
    22 0D 0A

    In English Windows' Notepad, the code shows as:

    wscript.echo "ÁÃÄÆÇÈÉ"

    When run with CSCRIPT from the command prompt, it'll displays the incorrect characters:


    I've tried switching to code page 1251 using the CHCP command like below, but the result is the same. e.g.

    chcp 1251
    cscript test.vbs

    I also found out about the `//CP` command line switch to specify a code page, but it's not clear to which/what part(s) does that command line switch applies to. Anyone know?

    Anyway... I've also tried using that switch like below, but still same result.

    cscript //cp:1251 test.vbs

    And combine it with the `chcp` command. e.g.

    chcp 1251
    cscript //cp:1251 test.vbs

    I've also tried other Cyrillic code pages 21866 and 866, but same thing.

    So, how to properly run the script so that it'll display the correct Cyrillic characters? Without changing the script file encoding to UTF16, or modifying it in any way.

    Monday, February 24, 2020 5:21 AM

All replies

  • Change the locale of you Windows session.   The codepage affects reading but not writing.  Output from code is controlled by the display environment which is set to your local settings.

    The purpose of Unicode is to prevent just this issue and to circles you have to go in to get what you want.

    An easier way to fix this is to use PowerShell and forget VBScript.  It is obsolete and will no longer be able to give you what is needed in modern Windows.


    Monday, February 24, 2020 2:12 PM
  • This is how you code look in PowerSHell:

    PS C:\scripts> Write-Host "БГДЖЗИЙ"
    PS C:\scripts>


    • Edited by jrv Monday, February 24, 2020 2:14 PM
    Monday, February 24, 2020 2:14 PM