NAME

Tags::Utils - Utils module for Tags.

SYNOPSIS

use Tags::Utils qw(encode_newline encode_attr_entities encode_char_entities);
my $string_with_encoded_newline = encode_newline("foo\nbar");
my $string_with_encoded_attr_entities = encode_attr_entities('<data & "data"');
my $string_with_encoded_char_entities = encode_char_entities('<data & data');

SUBROUTINES

encode_newline($string)
Encode newline to '\n' string.
encode_attr_entities($data_r)
Decode all '&..;' strings.
Encode '<', '&' and '"' entities to '&..;' string.

$data_r can be:
- Scalar. Returns encoded scalar.
- Scalar reference. Returns undef.
- Array reference of scalars. Returns undef.
encode_char_entities($data_r)
Decode all '&..;' strings.
Encode '<', '&' and 'non-break space' entities to '&..;' string.

$data_r can be:
- Scalar. Returns encoded scalar.
- Scalar reference. Returns undef.
- Array reference of scalars. Returns undef.

ERRORS

encode_attr_entities():
        Reference '%s' doesn't supported.

encode_char_entities():
        Reference '%s' doesn't supported.

EXAMPLE1

# Pragmas.
use strict;
use warnings;

# Modules.
use Tags::Utils qw(encode_newline);

# Input text.
my $text = <<'END';
foo
bar
END

# Encode newlines.
my $out = encode_newline($text);

# Print out.
print $out."\n";

# Output:
# foo\nbar\n

EXAMPLE2

# Pragmas.
use strict;
use warnings;

# Modules.
use Dumpvalue;
use Tags::Utils qw(encode_attr_entities);

# Input data.
my @data = ('&', '<', '"');

# Encode.
encode_attr_entities(\@data);

# Dump out.
my $dump = Dumpvalue->new;
$dump->dumpValues(\@data);

# Output:
# 0  ARRAY(0x8b8f428)
#    0  '&amp;'
#    1  '&lt;'
#    2  '&quot;'

DEPENDENCIES

HTML::Entities, Error::Pure, Readonly.

SEE ALSO

Tags, Tags::Output, Tags::Output::Raw.

REPOSITORY

https://github.com/tupinek/Tags

AUTHOR

Michal Špaček mailto:skim@cpan.org

http://skim.cz/

LICENSE AND COPYRIGHT

BSD license.

VERSION

0.01