Changeset 25690

Show
Ignore:
Timestamp:
12/02/08 17:37:21 (5 weeks ago)
Author:
miyagawa
Message:

Added Path::Class::File->ufile

Location:
lang/perl/Path-Class-URI/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Path-Class-URI/trunk/lib/Path/Class/Unicode.pm

    r25675 r25690  
    1919sub udir { 
    2020    __PACKAGE__->new(dir(@_)); 
     21} 
     22 
     23sub Path::Class::File::ufile { 
     24    my $file = shift; 
     25    ufile(_decode_filename($file), @_); 
     26} 
     27 
     28sub Path::Class::Dir::udir { 
     29    my $dir = shift; 
     30    udir(_decode_filename($dir), @_); 
    2131} 
    2232 
     
    6676our $encoding; 
    6777 
    68 sub stringify { 
    69     my $self = shift; 
    70  
     78sub init_encoding { 
    7179    unless ($encoding) { 
    7280        $encoding = 'utf-8'; 
     
    7987        } 
    8088    } 
     89} 
    8190 
     91sub stringify { 
     92    my $self = shift; 
     93    init_encoding(); 
    8294    Encode::encode($encoding, $self->{path}->stringify); 
     95} 
     96 
     97sub _decode_filename { 
     98    init_encoding(); 
     99    my $filename = shift; 
     100    Encode::decode($encoding, "$filename"); 
    83101} 
    84102 
  • lang/perl/Path-Class-URI/trunk/t/02_unicode.t

    r25665 r25690  
    44use Path::Class; 
    55use Path::Class::Unicode; 
    6 plan tests => 4 * blocks; 
     6plan tests => 5 * blocks; 
    77 
    88filters 'chomp', 'eval_str'; 
     
    1616    is $f2, $f; 
    1717 
    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; 
    2021 
    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; 
    2327}; 
    2428