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.

For example, the "=" sign, ASCII 61 or \x3d, will be converted to +3D.


encode_xtext ($string_to_encode)

Expects a non-unicode-string to encode in xtext encoding. Returns the encoded text.

decode_xtext ($string_to_decode)

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 );

SEE ALSO - The original xtext definition - Special usage of xtext encoding


Chr. Winter, <>


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.