Why don't scripting languages output Unicode to the Windows console?

前端 未结 9 1587
迷失自我
迷失自我 2020-12-08 11:18

The Windows console has been Unicode aware for at least a decade and perhaps as far back as Windows NT. However for some reason the major cross-platform scripting languages

9条回答
  •  情歌与酒
    2020-12-08 11:45

    For Perl to fully support Windows in this way, every call to print printf say warn and die has to be modified.

    • Is this Windows?
    • Which version of Windows? Perl still mostly works on Windows 95
    • Is this going to the console, or somewhere else.

    Once you have that determined, you then have to use a completely different set of API functions.

    If you really want to see everything involved in doing this properly, have a look at the source of Win32::Unicode::Console.


    On Linux, OpenBSD, FreeBSD and similar OS's you can usually just call binmode on the STDOUT and STDERR file handles.

    binmode STDOUT, ':utf8';
    binmode STDERR, ':utf8';
    

    This assumes that the terminal is using the UTF-8 encoding.

提交回复
热议问题