Perl on Windows: Problems with Encoding

扶醉桌前 提交于 2019-12-03 17:32:21

use utf8; simply tells Perl your source is encoded using UTF-8.

It's not working on unix either. There are some strings that won't print properly (print chr(0xE9);), and most that do will print a "Wide character" warning (print chr(0x2660);). You need decode your inputs and encode your outputs.

In unix systems, that's usuaully

use open ':std', ':encoding(UTF-8)';

In Windows system, you'll need to use chcp to find the console's character page. (437 for me.)

use open ':std', ':encoding(cp437)';  # Encoding used by console
use open IO => ':encoding(cp1252)';   # Encoding used by files
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!