这是我的测试代码:我正在使用win32草莓perl.
使用utf8 :: all; 我的$ input =;
当键入汉字时,
它显示错误:
utf8 "\xAD" does not map to unicode .....
Run Code Online (Sandbox Code Playgroud)
我也用utf8编写了一个脚本:: all来打印汉字,不能成功.如果只使用utf8或没有utf8,我可以通过编码来打印中文字符.
如何设置其他编码?
如何设置其他编码?
有utf8::all,你不能.编码UTF-8在其中的每个地方都是硬编码的.毕竟,模块是命名的,utf8::all而不是big5::all.
您必须明确解码/编码,请参阅http://p3rl.org/UNI.你说你在Windows上,所以采用编码cp950.
use Encode qw(decode encode);
my @arguments_as_characters = decode 'cp950', @ARGV;
open my $file_handle, '<:encoding(cp950)', $file_name;
print encode 'cp950', $data_to_stdout;
Run Code Online (Sandbox Code Playgroud)
如何在cp950中打开STDIN,STDOUT?
当你运行你的程序,标准流是已经打开!您可以修改I/O层用binmode.
binmode STDOUT, ':encoding(cp950)';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
929 次 |
| 最近记录: |