📄 quotedprint.t
字号:
BEGIN { # Magic Perl CORE pragma if ($ENV{PERL_CORE}) { chdir 't' if -d 't'; @INC = '../lib'; } unless (find PerlIO::Layer 'perlio') { print "1..0 # Skip: PerlIO not used\n"; exit 0; } require Config; if (($Config::Config{'extensions'} !~ m!\bPerlIO/via\b!) ){ print "1..0 # Skip -- Perl configured without PerlIO::via module\n"; exit 0; } if (ord("A") == 193) { print "1..0 # Skip: EBCDIC\n"; }}use strict;use warnings;use Test::More tests => 11;BEGIN { use_ok('PerlIO::via::QuotedPrint') }my $file = 'test.qp';my $decoded = <<EOD;This is a t閟t for quoted-printable text that has h鄏dly any spe鏸al charactersin it.EODmy $encoded;if (ord('A') == 193) { # EBCDIC. $encoded = <<EOD;This is a t=51st for quoted-printable text that has h=44rdly any spe=48ial =charactersin it.EOD} else { $encoded = <<EOD;This is a t=E9st for quoted-printable text that has h=E0rdly any spe=E7ial =charactersin it.EOD}# Create the encoded test-fileok( open( my $out,'>:via(PerlIO::via::QuotedPrint)', $file ), "opening '$file' for writing");ok( (print $out $decoded), 'print to file' );ok( close( $out ), 'closing encoding handle' );# Check encoding without layers{local $/ = undef;ok( open( my $test,$file ), 'opening without layer' );is( $encoded,readline( $test ), 'check encoded content' );ok( close( $test ), 'close test handle' );}# Check decoding _with_ layersok( open( my $in,'<:via(QuotedPrint)', $file ), "opening '$file' for reading");is( $decoded,join( '',<$in> ), 'check decoding' );ok( close( $in ), 'close decoding handle' );# Remove whatever we created nowok( unlink( $file ), "remove test file '$file'" );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -