NAME

PYX::Utils - A perl module for PYX common utilities.

SYNOPSIS

my $decoded_text = decode($text);
my $encoded_text = encode($text);
my $decoded_text = entity_decode($text);
my $encoded_text = entity_encode($text);

SUBROUTINES

decode($text)
Decode characters.
Currently decode newline to '\n'.
Returns decoded text.
encode($text)
Encode characters.
Currently encode '\n' to newline.
Returns encoded text.
entity_decode($text)
Decode entities.
- '&lt;' => '<'
- '&amp;' => '&'
- '&quot;' => '"'
Returns decoded text.
entity_encode($text)
Encode some chars for HTML/XML/SGML.
Currenctly encode these characters:
- '<' => '&lt;'
- '&' => '&amp;'
- '"' => '&quot;'
Returns encoded text.

EXAMPLE1

# Pragmas.
use strict;
use warnings;

# Modules.
use PYX::Utils qw(decode);

# Text.
my $text = "foo\nbar";

# Decode.
my $decoded_text = decode($text);

# Print to output.
print "Text: $text\n";
print "Decoded text: $decoded_text\n";

# Output:
# Text: foo
# bar
# Decoded text: foo\nbar

EXAMPLE2

# Pragmas.
use strict;
use warnings;

# Modules.
use PYX::Utils qw(encode);

# Text.
my $text = 'foo\nbar';

# Encode text.
my $encoded_text = encode($text);

# Print to output.
print "Text: $text\n";
print "Encoded text: $encoded_text\n";

# Output:
# Text: foo\nbar
# Encoded text: foo
# bar

EXAMPLE3

# Pragmas.
use strict;
use warnings;

# Modules.
use PYX::Utils qw(entity_decode);

# Text.
my $text = 'foo&lt;&amp;&quot;bar';

# Decode entities.
my $decoded_text = entity_decode($text);

# Print to output.
print "Text: $text\n";
print "Decoded entities: $decoded_text\n";

# Output:
# Text: foo&lt;&amp;&quot;bar
# Decoded entities: foo<&"bar

EXAMPLE4

# Pragmas.
use strict;
use warnings;

# Modules.
use PYX::Utils qw(entity_encode);

# Text.
my $text = 'foo<&"bar';

# Encode entities.
my $encoded_text = entity_encode($text);

# Print to output.
print "Text: $text\n";
print "Encoded text: $encoded_text\n";

# Output:
# Text: foo<&"bar
# Encoded text: foo&lt;&amp;&quot;bar

DEPENDENCIES

Exporter, HTML::Entities, Readonly.

SEE ALSO

App::SGML2PYX, PYX::Checker, PYX::Filter, PYX::GraphViz, PYX::Optimalization, PYX, PYX::Parser, PYX::Sort, PYX::Stack, PYX::Write::Raw, PYX::Write::Tags, PYX::Write::Tags::Code, PYX::XMLNorm.

AUTHOR

Michal Špaček skim@cpan.org

LICENSE AND COPYRIGHT

BSD 2-Clause License

VERSION

0.01