| blib/lib/Convert/XText.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % |
| statement | 17 | 17 | 100.0 |
| branch | n/a | ||
| condition | n/a | ||
| subroutine | 5 | 5 | 100.0 |
| pod | 2 | 2 | 100.0 |
| total | 24 | 24 | 100.0 |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | package Convert::XText; | ||||||
| 2 | |||||||
| 3 | 1 | 1 | 23825 | use strict; | |||
| 1 | 3 | ||||||
| 1 | 36 | ||||||
| 4 | 1 | 1 | 5 | use warnings; | |||
| 1 | 3 | ||||||
| 1 | 40 | ||||||
| 5 | |||||||
| 6 | our $VERSION = "0.01"; | ||||||
| 7 | |||||||
| 8 | 1 | 1 | 5 | use Exporter; | |||
| 1 | 7 | ||||||
| 1 | 259 | ||||||
| 9 | |||||||
| 10 | our @ISA = qw(Exporter); | ||||||
| 11 | |||||||
| 12 | our @EXPORT_OK = qw(decode_xtext encode_xtext); | ||||||
| 13 | |||||||
| 14 | sub encode_xtext { | ||||||
| 15 | 1 | 1 | 1 | 11 | my $input = shift; | ||
| 16 | 1 | 11 | $input =~ s/([^!-*,-<>-~])/'+'.uc(unpack('H*', $1))/eg; | ||||
| 4 | 24 | ||||||
| 17 | 1 | 14 | return $input; | ||||
| 18 | } | ||||||
| 19 | |||||||
| 20 | sub decode_xtext { | ||||||
| 21 | 1 | 1 | 1 | 3 | my $input = shift; | ||
| 22 | 1 | 6 | $input =~ s/\+([0-9A-F]{2})/chr(hex($1))/eg; | ||||
| 4 | 14 | ||||||
| 23 | 1 | 5 | return $input; | ||||
| 24 | } | ||||||
| 25 | |||||||
| 26 | 1; | ||||||
| 27 | __END__ |