在Windows中使用外来字符的Perl
我试图在Windows中使用perl以土耳其语打印像ş、ı、ö、ç这样的字符,但我做不到。我的主要目的是在Windows中使用特殊字符创建文件夹 这是我的代码:在Windows中使用外来字符的Perl,perl,file,utf-8,Perl,File,Utf 8,我试图在Windows中使用perl以土耳其语打印像ş、ı、ö、ç这样的字符,但我做不到。我的主要目的是在Windows中使用特殊字符创建文件夹 这是我的代码: use Text::Iconv; use strict; use warnings; $conve = Text::Iconv->new("windows-1254","UTF-16"); $converted = $conve->convert("ş"); print $con
use Text::Iconv;
use strict;
use warnings;
$conve = Text::Iconv->new("windows-1254","UTF-16");
$converted = $conve->convert("ş");
print $converted;
system("mkdir $converted");
我在第7行得到一个格式错误的utf-8字符(字节0xfe)aa.pl
use utf8;
use strict;
use warnings;
use open ":std", ":encoding(cp1254)"; # Set encoding for STD*
use Encode qw( encode );
my $file_name = "ş";
print "$file_name\n";
system(encode('cp1254', qq{mkdir "$file_name"}));
使用utf8
告诉Perl源代码是UTF-8
使用open:std“,”:编码(cp1254)”
使发送到STDOUT和STDERR的文本使用cp1254编码,并使从STDIN读取的文本从cp1254解码
它不会影响发送到系统调用(如
system
)的内容,因此您需要对这些内容进行显式编码。您得到的输出是什么?包括使用严格;使用警告;使用utf8代码>同样,您的代码在源代码中有UTF-8字符。还感谢您告诉我如何使用基本perl打印或在源代码中使用字符来打印字符串variable@AnonSr,这两个都是在已经存在的代码中完成的。