简体   繁体   中英

How to handle encoding when using Win32::Console::ANSI in a module?

Win32::Console::ANSI enables by default a ANSI(Win) to OEM(Dos) mapping. When I use Win32::Console::ANSI in a CPAN module should I keep this mapping or should I disable this mapping with \\e(U ?

The documentation outlines the reason this is the default:

It is useful because one types the script with a Windows-based editor (using a Windows codepage) and the script prints its messages on the console using another codepage: without translation, the characters with a code greatest than 127 are different and the printed messages may be not readable.

That seems to be a sensible default for an ANSI console emulation, as it aims to avoid unreadable messages. If, when people are using your CPAN module, they can reasonably expect an ANSI console, maybe it's wise to leave the defaults as they are. What you might want to do is allow people to choose the behaviour as an option when they load/configure your module. But in any case, make it really clear in the documentation what you're doing and why.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM