Use of 'use utf8;' gives me 'Wide character in print'

后端 未结 6 719
孤街浪徒
孤街浪徒 2020-12-02 05:25

If I run the following Perl program:

perl -e \'use utf8; print \"鸡\\n\";\'

I get this warning:

Wide character in print at -         


        
6条回答
  •  死守一世寂寞
    2020-12-02 05:52

    You can get close to "just do utf8 everywhere" by using the CPAN module utf8::all.

    perl -Mutf8::all -e 'print "鸡\n";'
    

    When print receives something that it can't print (character larger than 255 when no :encoding layer is provided), it assumes you meant to encode it using UTF-8. It does so, after warning about the problem.

提交回复
热议问题