| 1 |
|
| 2 |
=head1 NAME |
| 3 |
|
| 4 |
SuikaWiki::DB::FileSystem::Pescaped - "PLUS SIGN escaped" Filename Submodule |
| 5 |
|
| 6 |
=head1 SYNOPSIS |
| 7 |
|
| 8 |
package SomeWikiDB; |
| 9 |
require SuikaWiki::DB::FileSystem::Pescaped; |
| 10 |
push our @ISA, qw(SuikaWiki::DB::FileSystem::Pescaped |
| 11 |
SuikaWiki::DB::FileSystem::Base); |
| 12 |
|
| 13 |
...WikiDB implementation... |
| 14 |
|
| 15 |
=head1 DESCRIPTION |
| 16 |
|
| 17 |
C<SuikaWiki::DB::FileSystem::Pescaped> provides directory- and file-escaping |
| 18 |
internal-methods, which escape alphanumerics ([0-9A-Za-z_-]) in ASCII and |
| 19 |
others in base 16 prefixed by PLUS SIGN (+). |
| 20 |
|
| 21 |
This module is intended to be used as one of superclass for WikiDB |
| 22 |
implementing class that extends C<SuikaWiki::DB::File::System::Base>. |
| 23 |
|
| 24 |
This module is part of SuikaWiki. |
| 25 |
|
| 26 |
=cut |
| 27 |
|
| 28 |
package SuikaWiki::DB::FileSystem::Pescaped; |
| 29 |
use strict; |
| 30 |
our $VERSION=do{my @r=(q$Revision: 1.2 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
| 31 |
|
| 32 |
sub __encode_base16 ($$) { |
| 33 |
my (undef, $s) = @_; |
| 34 |
## TODO: utf8 support |
| 35 |
$s =~ s/([^A-Za-z0-9_-])/sprintf '+%02X', ord $1/ges; |
| 36 |
$s; |
| 37 |
} |
| 38 |
|
| 39 |
sub __decode_base16 ($$) { |
| 40 |
my (undef, $s) = @_; |
| 41 |
$s =~ s/\+([0-9A-Fa-f][0-9A-Fa-f])/pack 'C', hex $1/ge; |
| 42 |
## TODO: utf8 support |
| 43 |
$s; |
| 44 |
} |
| 45 |
|
| 46 |
=head1 EXAMPLE |
| 47 |
|
| 48 |
See C<SuikaWiki::DB::FileSystem::LeafFileP>. |
| 49 |
|
| 50 |
=head1 LICENSE |
| 51 |
|
| 52 |
Copyright 2004 Wakaba <w@suika.fam.cx>. All rights reserved. |
| 53 |
|
| 54 |
This program is free software; you can redistribute it and/or |
| 55 |
modify it under the same terms as Perl itself. |
| 56 |
|
| 57 |
=cut |
| 58 |
|
| 59 |
1; # $Date:$ |