Yanor.net/
Wiki
Blog
GitHub
Sandbox
開始行:
* 日本語テキストファイルの操作 - binmode() [#rc3884f9]
すでに開かれているファイルハンドル(STDIN/STDOUTを含む)...
*** use UTF8なスクリプト内で標準入力(出力)を使う [#a615...
use utf8;
binmode STDOUT, ':utf8'; # 'encoding(utf8)'でもよい
print "あ 京\n";
↑binmodeを使わなければ「Wide character」のシステムエラー...
use utf8;
binmode STDIN, ':utf8';
while (<>) {
chomp;
print "[$_]\n";
}
*** use utf8なスクリプト内で、SJISのテキストファイルを読...
use utf8;
binmode STDOUT, ':encoding(utf8)';
open my $fh, '<', shift;
binmode $fh, ':encoding(sjis)';
while ($row = <$fh>) {
print $row;
}
close $fh;
終了行:
* 日本語テキストファイルの操作 - binmode() [#rc3884f9]
すでに開かれているファイルハンドル(STDIN/STDOUTを含む)...
*** use UTF8なスクリプト内で標準入力(出力)を使う [#a615...
use utf8;
binmode STDOUT, ':utf8'; # 'encoding(utf8)'でもよい
print "あ 京\n";
↑binmodeを使わなければ「Wide character」のシステムエラー...
use utf8;
binmode STDIN, ':utf8';
while (<>) {
chomp;
print "[$_]\n";
}
*** use utf8なスクリプト内で、SJISのテキストファイルを読...
use utf8;
binmode STDOUT, ':encoding(utf8)';
open my $fh, '<', shift;
binmode $fh, ':encoding(sjis)';
while ($row = <$fh>) {
print $row;
}
close $fh;
ページ名: