Changeset 18391
- Timestamp:
- 08/28/08 17:24:47 (4 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Acme-Encode-WhiteSpace8/trunk/lib/Acme/Encode/WhiteSpace8.pm
r18389 r18391 16 16 17 17 my %whitespaces2bit = ( 18 "\t" => "00", 19 "\r" => "01", 20 "\n" => "10", 21 " " => "11", 18 " " => "0000", 19 "\001" => "0001", 20 "\002" => "0010", 21 "\003" => "0011", 22 "\004" => "0100", 23 "\005" => "0101", 24 "\006" => "0110", 25 "\007" => "0111", 26 27 "\010" => "1000", 28 "\011" => "1001", 29 "\013" => "1010", 30 "\014" => "1011", 31 "\016" => "1100", 32 "\017" => "1101", 33 "\020" => "1110", 34 "\021" => "1111", 22 35 ); 23 36 my %bit2whitespaces = map { $whitespaces2bit{$_} => $_ } keys %whitespaces2bit; … … 28 41 my $bytes = Encode::encode('utf8', $str); 29 42 my $bits = unpack('B*', $bytes); 30 $bits =~ s/([01][01] )/$bit2whitespaces{$1}/g;43 $bits =~ s/([01][01][01][01])/$bit2whitespaces{$1}/g; 31 44 $bits; 32 45 } … … 35 48 my ($obj, $bytes, $chk) = @_; 36 49 return '' unless $bytes; 37 return $bytes unless $bytes =~ /^[ \t\r\n ]{4,}$/;50 return $bytes unless $bytes =~ /^[ \001\002\003\004\005\006\007\010\011\013\014\016\017\020\021]{2,}$/; 38 51 39 52 my @bits = map { … … 42 55 43 56 my $ret = ''; 44 while (my @byte = splice @bits, 0, 4) {57 while (my @byte = splice @bits, 0, 2) { 45 58 $ret .= pack('B8', join '', @byte); 46 59 } 47 48 60 $ret; 49 61 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)