view release on metacpan or search on metacpan
# ok( $utf_8 !~ $Email::Address::addr_spec, "...it !~ addr_spec");
}
{
my (@addr) = Email::Address->parse($text);
is(@addr, 0, "unicode (decoded) address: not ok");
# ok( $text =~ $Email::Address::addr_spec, "...it !~ addr_spec");
}
{
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Email/Barcode/Decode.pm view on Meta::CPAN
my $ebd = Email::Barcode::Decode->new(email => $msg);
my @symbols = $ebd->get_symbols;
foreach my $symbol (@symbols) {
print(
'decoded ' . $symbol->{type} .
' symbol "' . $symbol->{data} .'"'.
' file "' . $symbol->{filename} .'"'.
"\n"
);
}
view all matches for this distribution
view release on metacpan or search on metacpan
t/UTF-8_html.t view on Meta::CPAN
binmode $builder->failure_output, ":encoding(UTF-8)";
binmode $builder->todo_output, ":encoding(UTF-8)";
my $response = LWP::UserAgent->new->get("file://$Bin/data/UTF-8.html");
my $body = $response->decoded_content;
my $from = generate_address('Föö', 'test@foo.example');
my $to = generate_address('Bäz', 'test@baz.example');
my $subject = encode_mimeword(encode_utf8('Sübject'), 'Q', 'UTF-8');
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Email/MIME/Encodings.pm view on Meta::CPAN
#pod =head1 SYNOPSIS
#pod
#pod use Email::MIME::Encodings;
#pod my $encoded = Email::MIME::Encodings::encode(base64 => $body);
#pod my $decoded = Email::MIME::Encodings::decode(base64 => $encoded);
#pod
#pod If a third argument is given, it is the encoding to which to fall back. If no
#pod valid codec can be found (considering both the first and third arguments) then
#pod an exception is raised.
#pod
lib/Email/MIME/Encodings.pm view on Meta::CPAN
=head1 SYNOPSIS
use Email::MIME::Encodings;
my $encoded = Email::MIME::Encodings::encode(base64 => $body);
my $decoded = Email::MIME::Encodings::decode(base64 => $encoded);
If a third argument is given, it is the encoding to which to fall back. If no
valid codec can be found (considering both the first and third arguments) then
an exception is raised.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Email/MIME/Kit/Assembler/Markdown.pm view on Meta::CPAN
}
sub assemble {
my ($self, $stash) = @_;
my $markdown = ${ $self->kit->get_decoded_kit_entry( $self->path ) };
my $plaintext = $markdown;
if ($self->renderer) {
{
lib/Email/MIME/Kit/Assembler/Markdown.pm view on Meta::CPAN
for my $type (keys %content) {
my $type_wrapper = "$type\_wrapper";
if (my $wrapper_path = $self->$type_wrapper) {
my $wrapper = ${ $self->kit->get_decoded_kit_entry($wrapper_path) };
if ($self->render_wrapper) {
local $stash->{wrapped_content} = $content{$type};
local $stash->{part_type} = $type;
my $output_ref = $self->renderer->render(\$wrapper, $stash);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Email/MIME/Kit.pm view on Meta::CPAN
#pod render, and so on. This, further, means that strings passed to the C<assemble>
#pod method for use in rendering should also be text strings.
#pod
#pod In older versions of Email::MIME::Kit, files read from disk were read in raw
#pod mode and then handled as octet strings. Meanwhile, the manifest's contents
#pod (and, thus, any templates stored as strings in the manifest) were decoded into
#pod text strings. This could lead to serious problems. For example: the
#pod F<manifest.json> file might contain:
#pod
#pod "header": [
#pod { "Subject": "Message for [% customer_name %]" },
lib/Email/MIME/Kit.pm view on Meta::CPAN
has manifest => (reader => 'manifest', writer => '_set_manifest');
my @auto_attrs = (
[ manifest_reader => ManifestReader => JSON => [ 'read_manifest' ] ],
[ kit_reader => KitReader => Dir => [ 'get_kit_entry',
'get_decoded_kit_entry' ] ],
);
for my $tuple (@auto_attrs) {
my ($attr, $role, $default, $handles) = @$tuple;
lib/Email/MIME/Kit.pm view on Meta::CPAN
render, and so on. This, further, means that strings passed to the C<assemble>
method for use in rendering should also be text strings.
In older versions of Email::MIME::Kit, files read from disk were read in raw
mode and then handled as octet strings. Meanwhile, the manifest's contents
(and, thus, any templates stored as strings in the manifest) were decoded into
text strings. This could lead to serious problems. For example: the
F<manifest.json> file might contain:
"header": [
{ "Subject": "Message for [% customer_name %]" },
view all matches for this distribution
view release on metacpan or search on metacpan
t/01_parse.t view on Meta::CPAN
my $mail = Email::MIME::MobileJP::Parser->new($src->as_string);
subtest 'subject' => sub {
is $mail->subject(), 'ã³ã³ããã¯';
ok Encode::is_utf8($mail->subject), 'decoded';
};
subtest 'carrier' => sub {
isa_ok $mail->carrier, 'Email::Address::JP::Mobile::DoCoMo';
is $mail->carrier->name, 'DoCoMo';
view all matches for this distribution
view release on metacpan or search on metacpan
);
for (my $i=0; $i<@tests; $i+=2) {
my ($encoded, $expect) = ($tests[$i], $tests[$i+1]);
my $decoded = $decoder->decode_phrase($encoded);
is($decoded, $expect, "decode_phrase $encoded");
}
view all matches for this distribution
view release on metacpan or search on metacpan
Content-Type header; it is now default to UTF-8.
0.40 Thu Aug 18 17:53:06 CEST 2005
- fixed nusty bug when serializing to XML headers combined with body. Make
sure that headers as decoded and body is a valid UTF-8 string into XML.
0.39 Thu Aug 18 01:44:46 CEST 2005
- fixed bug when Content-Type is not specified; and default to text/plain
(and do not base64-encode body text)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Email/MIME.pm view on Meta::CPAN
#pod
#pod use Email::MIME;
#pod my $parsed = Email::MIME->new($message);
#pod
#pod my @parts = $parsed->parts; # These will be Email::MIME objects, too.
#pod my $decoded = $parsed->body;
#pod my $non_decoded = $parsed->body_raw;
#pod
#pod my $content_type = $parsed->content_type;
#pod
#pod ...or...
#pod
lib/Email/MIME.pm view on Meta::CPAN
#pod =head1 DESCRIPTION
#pod
#pod This is an extension of the L<Email::Simple> module, to handle MIME
#pod encoded messages. It takes a message as a string, splits it up into its
#pod constituent parts, and allows you access to various parts of the
#pod message. Headers are decoded from MIME encoding.
#pod
#pod =head1 METHODS
#pod
#pod Please see L<Email::Simple> for the base set of methods. It won't take
#pod very long. Added to that, you have:
lib/Email/MIME.pm view on Meta::CPAN
use Email::MIME;
my $parsed = Email::MIME->new($message);
my @parts = $parsed->parts; # These will be Email::MIME objects, too.
my $decoded = $parsed->body;
my $non_decoded = $parsed->body_raw;
my $content_type = $parsed->content_type;
...or...
lib/Email/MIME.pm view on Meta::CPAN
=head1 DESCRIPTION
This is an extension of the L<Email::Simple> module, to handle MIME
encoded messages. It takes a message as a string, splits it up into its
constituent parts, and allows you access to various parts of the
message. Headers are decoded from MIME encoding.
=head1 PERL VERSION
This library should run on perls released even a long time ago. It should
work on any version of perl released in the last five years.
lib/Email/MIME.pm view on Meta::CPAN
=head2 header_str_pairs
my @pairs = $email->header_str_pairs;
This method behaves like C<header_raw_pairs>, returning a list of field
name/value pairs, but the values have been decoded to character strings, when
possible.
=head2 header_as_obj
my $first_obj = $email->header_as_obj($field);
lib/Email/MIME.pm view on Meta::CPAN
#pod =method header_str_pairs
#pod
#pod my @pairs = $email->header_str_pairs;
#pod
#pod This method behaves like C<header_raw_pairs>, returning a list of field
#pod name/value pairs, but the values have been decoded to character strings, when
#pod possible.
#pod
#pod =method header_as_obj
#pod
#pod my $first_obj = $email->header_as_obj($field);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Email/Outlook/Message.pm view on Meta::CPAN
sub _create_mime_plain_body {
my $self = shift;
my $charset = $self->_body_plain_character_set;
my $body_str = $self->{BODY_PLAIN};
if ($charset ne "UTF-8") {
# In this case, the body is a string of octets and needs to be decoded.
$body_str = Encode::decode($charset, $body_str);
}
return Email::MIME->create(
attributes => {
content_type => "text/plain",
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Email/Simple/Header.pm view on Meta::CPAN
#pod
#pod =method header
#pod
#pod This method just calls C<header_raw>. It's the older name for C<header_raw>,
#pod but it can be a problem because L<Email::MIME>, a subclass of Email::Simple,
#pod makes C<header> return the header's decoded value.
#pod
#pod =cut
sub _str_value { return ref $_[0] ? $_[0][0] : $_[0] }
lib/Email/Simple/Header.pm view on Meta::CPAN
=head2 header
This method just calls C<header_raw>. It's the older name for C<header_raw>,
but it can be a problem because L<Email::MIME>, a subclass of Email::Simple,
makes C<header> return the header's decoded value.
=head2 header_raw_set
$header->header_raw_set($field => @values);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Email/Stuffer/TestLinks.pm view on Meta::CPAN
my $response = shift;
return Future->fail("Response code was " . $response->code) if ($response->code !~ /^2\d\d/);
if ($response->content_type eq 'text/html') {
my $dom = Mojo::DOM->new($response->decoded_content);
if (my $title = $dom->at('title')) {
return Future->fail("Page title contains text '$1'") if $title->text =~ /(error|not found)/i;
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
Changes.pod view on Meta::CPAN
automaticly set status to 301.
- setting http headers and <META HTTP-EQUIV=..> now works also
in cgi mode.
- Session Handling now also works in CGI mode (needs
Apache::Session >= 1.04)
- ACTION attribute of Formtag is now URL en/decoded. Spotted by
Hartmut Palm.
=head1 1.2b9 (BETA) 10. Sept 1999
- Fixed a problem with loading Apache::Session 1.01, when
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Emoji/NationalFlag.pm view on Meta::CPAN
=head2 code2flag($iso_3166_1_alpha_2_code): Optional[NationalFlagEmoji]
This method returns national flag emoji if the supplied code (case insensitive) is valid, otherwise returns C<undef>
=head2 flag2code($decoded_national_flag_emoji): Optional[lc(CountryCodeAlpha-2)]
This method returns lower case of ISO 3166-1 alpha-2 country code if the supplied emoji is valid, otherwise returns C<undef>
=head1 AUTHOR
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Encode/Argv.pm view on Meta::CPAN
Encode::Argv - Automatically Mess With @ARGV's Encoding
=head1 SYNOPSIS
use Encode::Argv ('cp932');
# Now @ARGV is decoded unicode characters, decoded from cp932
use Encode::Argv ('cp932' => 'euc-jp');
# Now @ARGV is encoded into euc-jp after being decoded from cp932
use Encode::Argv;
# Now @ARGV is decoded from whatever Term::Encoding thinks you are
# using on your terminal.
=head1 DESCRIPTION
I saw L<http://search.cpan.org/dist/Sjis|Sjis.pm> and L<http://www.aritia.org/hizumi/perl/perlwin.html|this>, and thought, "Well, I can't fix /all/ of their
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Encode/Base32/Crockford.pm view on Meta::CPAN
or
use Encode::Base32::Crockford qw(base32_decode); # your choice of methods
my $decoded = base32_decode_with_checksum("16JD");
my $encoded = base32_encode_with_checksum(1234);
=head1 METHODS
=head2 base32_encode
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Encode/Base32/GMP.pm view on Meta::CPAN
base32hex: [0123456789ABCDEFGHIJKLMNOPQRSTUV]
gmp: [0123456789ABCDEFGHIJKLMNOPQRSTUV]
The encode_base32, decode_base32 and md5_base32 methods support an alphabet
parameter which can be set to the supported alphabets to indicate the value
to be encoded or decoded:
[qw/crockford rfc4648 base32hex zbase32 gmp/]
This module functions similarly to L<Encode::Base58::GMP> with Base32 being
ideal for case-insensitive encoding and Base58 being ideal for case-sensitive
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Encode/Base58/BigInt.pm view on Meta::CPAN
sub decode_base58 {
my $str = shift;
$str =~ tr/0OlI/DD11/;
$str =~ $reg or croak "Invalid Base58";
my $decoded = Math::BigInt->new(0);
my $multi = Math::BigInt->new(1);
my $base = @$chars;
while (length $str > 0) {
my $digit = chop $str;
$decoded->badd($multi->copy->bmul($map->{$digit}));
$multi->bmul($base);
}
"$decoded";
}
1;
__END__
lib/Encode/Base58/BigInt.pm view on Meta::CPAN
=head1 SYNOPSIS
use Encode::Base58::BigInt;
my $bigint = '9235113611380768826';
my $encoded = encode_base58($bigint);
my $decoded = decode_base58($short); # decoded is bigint string
=head1 DESCRIPTION
Encode::Base58::BigInt is a base58 encoder/decoder implementation in Perl.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Encode/Base58/GMP.pm view on Meta::CPAN
GMP Alphabet: [0-9A-Za-v]
The encode_base58, decode_base58 and md5_base58 methods support an alphabet
parameter which can be set to the supported alphabets ['bitcoin', 'flickr',
'gmp'] to indicate the value to be encoded or decoded.
=head2 Requirements
This module requires GMP 4.2.0 and above. Prior versions are limited to Base36.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Encode/Base58.pm view on Meta::CPAN
}
sub decode_base58 {
my $str = shift;
my $decoded = 0;
my $multi = 1;
my $base = @alpha;
while (length $str > 0) {
my $digit = chop $str;
$decoded += $multi * $alpha{$digit};
$multi *= $base;
}
return $decoded;
}
1;
__END__
view all matches for this distribution
view release on metacpan or search on metacpan
t/encodedecode.t view on Meta::CPAN
my $BS = new Encode::Bootstring();
my $raw = 'Búlgarska';
my $enc = $BS->encode( $raw );
my $dec = $BS->decode( $enc );
ok( $enc ne $dec, 'not encoded' );
ok( $dec eq $raw, 'decoded same as original' );
view all matches for this distribution
view release on metacpan or search on metacpan
sub decode ($$;$) {
my ($self, $octets, $check) = @_;
my $charset = detect($octets) || 'Windows-1252';
my $e = find_encoding($charset) or die "Unknown encoding: $charset";
my $decoded = $e->decode($octets, $check || 0);
$_[1] = $octets if $check;
return $decoded;
}
1;
__END__
view all matches for this distribution
view release on metacpan or search on metacpan
t/Encode-Escape-ASCII.t view on Meta::CPAN
$string = "\a\b\e\f\n\r\t\\\"\$\@";
$escaped = "\\a\\b\\e\\f\\n\\r\\t\\\\\\\"\\\$\\\@";
is $string,
(decode 'ascii-escape', $escaped),
'decoded character escape sequences';
is $escaped,
(encode 'ascii-escape', $string),
'encoded character escape sequences';
$string_oct = "\0\00\000\11\011\100";
$escaped_oct = "\\0\\00\\000\\11\\011\\100";
is $string_oct,
(decode 'ascii-escape', $escaped_oct),
'decoded octal escape sequences';
$string_hex = "\x09\x47\x57\x67\x77";
$escaped_hex = "\\x09\\x47\\x57\\x67\\x77";
is $string_hex,
(decode 'ascii-escape', $escaped_hex),
'decoded hex escape sequences';
$string_non_printing
= "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e" .
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e" .
"\x7f";
t/Encode-Escape-ASCII.t view on Meta::CPAN
"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\e\\x1c\\x1d\\x1e" .
"\\x7f";
is $string_non_printing,
(decode 'ascii-escape', $escaped_non_printing),
'decoded non-printing characters';
is $escaped_non_printing,
(encode 'ascii-escape', $string_non_printing),
'encoded non-printing characters';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Encode/Float.pm view on Meta::CPAN
for (my $i = 0 ; $i < 10 ; $i++)
{
my $float = (.5 - rand) * 10**int(10 - 20 * rand);
$float = 0 if $i == 0;
my $encoded = $encoder->encode($float);
my $decoded = $encoder->decode($encoded);
my $error = $encoder->getRelativeDifference($float, $decoded);
push @list, [ $encoded, $float, $decoded, $error ];
}
@list = sort { $a->[0] cmp $b->[0] } @list;
foreach (@list)
{
print join(',', @$_) . "\n";
view all matches for this distribution
view release on metacpan or search on metacpan
t/Encode-Korean-HSR.t view on Meta::CPAN
"anj.a anja " .
"anj.ja anjja " .
"anjjja" ;
my $encoded_ccs = encode 'hsr', $str_ccs;
my $decoded_ccs = decode 'hsr', $hsr_ccs;
my $decoded_ccs_smart_sep = decode 'hsr', $hsr_ccs_smart_sep;
is $encoded_ccs, $hsr_ccs, 'encoded complex consonants group';
is $decoded_ccs, $str_ccs, 'decoded complex consonants group';
is $decoded_ccs_smart_sep, $str_ccs, 'decoded complex consonants group with smart sep';
is $encoded_ccs, (encode 'hsr', $decoded_ccs), 'encode ($enc, $decoded)';
is $decoded_ccs, (decode 'hsr', $encoded_ccs), 'decode ($enc, $encoded)';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Encode/Locale.pm view on Meta::CPAN
=item decode_argv( Encode::FB_CROAK )
This will decode the command line arguments to perl (the C<@ARGV> array) in-place.
The function will by default replace characters that can't be decoded by
"\x{FFFD}", the Unicode replacement character.
Any argument provided is passed as CHECK to underlying Encode::decode() call.
Pass the value C<Encode::FB_CROAK> to have the decoding croak if not all the
command line arguments can be decoded. See L<Encode/"Handling Malformed Data">
for details on other options for CHECK.
=item env( $uni_key )
=item env( $uni_key => $uni_value )
lib/Encode/Locale.pm view on Meta::CPAN
Interface to get/set environment variables. Returns the current value as a
Unicode string. The $uni_key and $uni_value arguments are expected to be
Unicode strings as well. Passing C<undef> as $uni_value deletes the
environment variable named $uni_key.
The returned value will have the characters that can't be decoded replaced by
"\x{FFFD}", the Unicode replacement character.
There is no interface to request alternative CHECK behavior as for
decode_argv(). If you need that you need to call encode/decode yourself.
For example:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Encode/Positive/Digits.pm view on Meta::CPAN
"number of decoding digits supplied($b) too few, must be at least 2";
my @n = split //, $number;
my $n = @n;
for(1..$n) # Convert each digit to be decoded with its decimal equivalent
{my $d = $n[$_-1];
my $i = index($digits, $d);
$i < 0 and confess "Invalid digit \"$d\" in number $number at position $_";
$n[$_-1] = $i;
}
lib/Encode/Positive/Digits.pm view on Meta::CPAN
ok 5 == Encode::Positive::Digits::decode("101", "01");
ok "hello world" eq Encode::Positive::Digits::encode(4830138323689, " abcdefghlopqrw");
ok 4830138323689 == Encode::Positive::Digits::decode("hello world", " abcdefghlopqrw");
The numbers to be encoded or decoded can be much greater than 2**64 via support
from L<Math::BigInt>, such numbers should be placed inside strings to avoid
inadvertent truncation.
my $n = '1'.('0'x999).'1';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Encode/Repair.pm view on Meta::CPAN
# prints: beta: β
print repair_double("beta: \xc4\xaa\xc2\xb2\n", {via => 'Latin-7'});
# Advanced usage
# assumes you have a sample text both correctly decoded in a
# character string, and as a wrongly encoded buffer
use Encode::Repair qw(repair_encoding learn_recoding);
use charnames qw(:full);
binmode STDOUT, ':encoding(UTF-8)';
lib/Encode/Repair.pm view on Meta::CPAN
and was encoded as UTF-8 again. The other encoding defaults to ISO-8859-1 aka
Latin-1, and can be overridden with the C<via> option:
my $repaired = repair_double($buffer, {via => 'ISO-8859-2' });
It expects an octet string as input, and returns a decoded character string.
=item learn_recoding
Given a sample of text twice, once correctly decoded and once mistreated,
attemps to find a sequence of encoding and decoding that turns the mistreated
text into the correct form.
my $coding_pattern = learn_recoding(
from => $mistreated_buffer,
view all matches for this distribution
view release on metacpan or search on metacpan
Do not use it for data exchange.
Unless you want Perl's older "lax" mode, prefer
C<$string = decode("UTF-8", $octets [, CHECK])>.
Equivalent to C<$string = decode("utf8", $octets [, CHECK])>.
The sequence of octets represented by $octets is decoded
from (loose, not strict) utf8 into a sequence of logical characters.
Because not all sequences of octets are valid not strict utf8,
it is quite possible for this function to fail.
For CHECK, see L</"Handling Malformed Data">.
For encodings that are implemented by the C<Encode::XS> module, C<CHECK> C<==>
C<Encode::FB_PERLQQ> puts C<encode> and C<decode> into C<perlqq> fallback mode.
When you decode, C<\xI<HH>> is inserted for a malformed character, where
I<HH> is the hex representation of the octet that could not be decoded to
utf8. When you encode, C<\x{I<HHHH>}> will be inserted, where I<HHHH> is
the Unicode code point (in any number of hex digits) of the character that
cannot be found in the character repertoire of the encoding.
The HTML/XML character reference modes are about the same. In place of
$ascii = encode("ascii", $utf8, sub{ sprintf "<U+%04X>", shift });
Acts like C<FB_PERLQQ> but U+I<XXXX> is used instead of C<\x{I<XXXX>}>.
Fallback for C<decode> must return decoded string (sequence of characters)
and takes a list of ordinal values as its arguments. So for
example if you wish to decode octets as UTF-8, and use ISO-8859-15 as
a fallback for bytes that are not valid UTF-8, you could write
$str = decode 'UTF-8', $octets, sub {
view all matches for this distribution