YOU Hyun Jo
and 1 contributors

NAME

Encode::Escape::ASCII - Perl extension for Encoding of ASCII Escape Sequnces (or Escaped ASCII)

SYNOPSIS

  use Encode::Escape::ASCII;

  $escaped = "Perl\\tPathologically Eclectic Rubbish Lister\\n";
  $string = decode 'ascii-escape', $escaped;

  # Now, $string is equivalent to "Perl\tPathologically Eclectic Rubish Lister\n";

  $escaped = "\\x65\\x50\\x6c\\x72\\x50\\x09\\x74\\x61\\x6f\\x68\\x6f\\x6c" .
             "\\x69\\x67\\x61\\x63\\x6c\\x6c\\x20\\x79\\x63\\x45\\x65\\x6c" .
             "\\x74\\x63\\x63\\x69\\x52\\x20\\x62\\x75\\x73\\x69\\x20\\x68" .
             "\\x69\\x4c\\x74\\x73\\x72\\x65\\x0a";
  $string = decode 'ascii-escape', $escaped;

  # Now, $string is equivalent to "Perl\tPathologically Eclectic Rubish Lister\n";

If you have a text data file 'ascii-escape.txt'. It contains a line:

  Perl\tPathologically Eclectic Rubbish Lister\n

And you want to use it as if it were a normal double quote string in source code. Try this:

  open(FILE, 'ascii-escape.txt');
  while(<FILE>) {
    chomp;
    print decode 'ascii-escape', $_;
  }

DESCRIPTION

Encode::Escape::ASCII module implements encoding of ASCII escape sequences.

Simply saying, it converts (decodes) escape sequences into ASCII chracters (0x00 -- 0x7f) and converts (encodes) non-printable control characters into escape sequences.

It supports only ASCII character. ASCII is called as low ASCII or 7-bit ASCII when one distinguishes it from various extended ASCII codes, i.e. high ASCII or 8-bit ASCII.

Supproted Escape Sequences

 Escape Sequcnes      Description
 ---------------      --------------------------
 \a                   Alarm (beep)
 \b                   Backspace
 \e                   Escape
 \f                   Formfeed
 \n                   Newline
 \r                   Carriage return
 \t                   Tab
 \000     - \177      octal ASCII value. \0, \00, and \000 are equivalent.
 \x00     - \x7f      hexadecimal ASCII value. \x0 and \x00 are equivalent.
 \x{0000} - \x{007f}  hexadecimal ASCII value. \x{0}, \x{00}, x\{000}, \x{0000}


 \\                   Backslash
 \$                   Dollar Sign
 \@                   Ampersand
 \"                   Print double quotes
 \                    Escape next character if known otherwise print

AUTHOR

you, <you at cpan dot org>

COPYRIGHT AND LICENSE

Copyright (C) 2007 by you

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.