in reply to Re: Determine encoding of STDOUT
in thread Determine encoding of STDOUT

I think you are right. The best way is to write in the help of the script that its STDOUT is encoded as UTF8.

I looked around how to do change the encoding of "cmd.exe".

I could do it temporarily as follows:

But the change of the new codepage 65001 is NOT stored permanently. If I open a new "cmd.exe" its codepage is 437 again.

A bit offtopic because this question is windows specific and not perl: Do you know how to change the codepage permanently to 65001 in Windows XP?

Would you recommend to write the following code at the beginning of the script:

`chcp 65001`;

So I would assure that the encoding is UTF8. Of course I should find out the active codepage (e.g. 437) at the beginning of the script and then restore it at the end (perhaps in an END block). And I should also do it dependent on the OS. This for example would be a windows specific solution.

Replies are listed 'Best First'.
Re^3: Determine encoding of STDOUT
by Jenda (Abbot) on May 04, 2011 at 15:46 UTC

    You might change the shortcut to Command Prompt to run the chcp automatically. For example my shortcut contains %windir%\system32\cmd.exe /F:ON /k doskey /macrofile="%USERPROFILE%\doskey.mac"

    The /k means "run this and stay open".

    You can also set a hotkey for the program and start it by , say, CTRL+SHIFT+`.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.