Convert::XText - Convert from and to RFC 1891 xtext encoding
use Convert::XText; my $encoded = Convert::XText::encode_xtext('String to=encode'); # $encoded contains "String+20to+3Dencode" my $decoded = Convert::XText::decode_xtext($encoded); # $decoded contains 'String to=encode'
RFC1891 defines the xtext encoding for delivery service notifications, to encode non-standard-ascii characters and special chars in a simple and fast, as well as easily reversible, way.
The input data for encode_xtext simply converts all characters outside the range of chr(33) (!) to chr(126) (~), as well as the plus (+) and equal (=) sign, into a plus sign followed by a two digit uppercase hexadecimal representation of the character code.
chr(33)
chr(126)
For example, the "=" sign, ASCII 61 or \x3d, will be converted to +3D.
Expects a non-unicode-string to encode in xtext encoding. Returns the encoded text.
Expects an xtext-encoded string and returns the decoded string.
None by default.
You can manually export encode_xtext and decode_xtext:
use Convert::XText qw(encode_xtext); encode_xtext( $string_to_encode );
http://www.faqs.org/rfcs/rfc1891.html - The original xtext definition
http://www.postfix.org/XCLIENT_README.html - Special usage of xtext encoding
Chr. Winter, <CHRWIN@cpan.org>
Copyright (C) 2007 by Chr. Winter
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install Convert::XText, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Convert::XText
CPAN shell
perl -MCPAN -e shell install Convert::XText
For more information on module installation, please visit the detailed CPAN module installation guide.