Changeset 25690
- Timestamp:
- 12/02/08 17:37:21 (5 weeks ago)
- Location:
- lang/perl/Path-Class-URI/trunk
- Files:
-
- 2 modified
-
lib/Path/Class/Unicode.pm (modified) (3 diffs)
-
t/02_unicode.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Path-Class-URI/trunk/lib/Path/Class/Unicode.pm
r25675 r25690 19 19 sub udir { 20 20 __PACKAGE__->new(dir(@_)); 21 } 22 23 sub Path::Class::File::ufile { 24 my $file = shift; 25 ufile(_decode_filename($file), @_); 26 } 27 28 sub Path::Class::Dir::udir { 29 my $dir = shift; 30 udir(_decode_filename($dir), @_); 21 31 } 22 32 … … 66 76 our $encoding; 67 77 68 sub stringify { 69 my $self = shift; 70 78 sub init_encoding { 71 79 unless ($encoding) { 72 80 $encoding = 'utf-8'; … … 79 87 } 80 88 } 89 } 81 90 91 sub stringify { 92 my $self = shift; 93 init_encoding(); 82 94 Encode::encode($encoding, $self->{path}->stringify); 95 } 96 97 sub _decode_filename { 98 init_encoding(); 99 my $filename = shift; 100 Encode::decode($encoding, "$filename"); 83 101 } 84 102 -
lang/perl/Path-Class-URI/trunk/t/02_unicode.t
r25665 r25690 4 4 use Path::Class; 5 5 use Path::Class::Unicode; 6 plan tests => 4* blocks;6 plan tests => 5 * blocks; 7 7 8 8 filters 'chomp', 'eval_str'; … … 16 16 is $f2, $f; 17 17 18 $Path::Class::Unicode::encoding = "utf-8"; 19 is file($f2->stringify)->basename, $block->local_utf8; 18 { 19 local $Path::Class::Unicode::encoding = "utf-8"; 20 is file($f2->stringify)->basename, $block->local_utf8; 20 21 21 $Path::Class::Unicode::encoding = "cp932"; 22 is file($f2->stringify)->basename, $block->local_cp932; 22 local $Path::Class::Unicode::encoding = "cp932"; 23 is file($f2->stringify)->basename, $block->local_cp932; 24 } 25 26 is file($f2->stringify)->ufile, $f; 23 27 }; 24 28
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)