view release on metacpan or search on metacpan
lib/Data/Recursive/Encode.pm view on Meta::CPAN
=item decode
my $ret = Data::Recursive::Encode->decode($encoding, $data, [CHECK]);
Returns a structure containing nodes which are decoded from the specified
encoding.
=item encode
my $ret = Data::Recursive::Encode->encode($encoding, $data, [CHECK]);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Riak/Result/JSONValue.pm view on Meta::CPAN
version 2.0
=head1 DESCRIPTION
Results for requests resulting in JSON data use this role to provide convenient
access to the decoded body payload.
=head1 METHODS
=head2 json_value
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Sah/Filter/perl/Str/try_decode_json.pm view on Meta::CPAN
my $res = {};
$res->{modules}{"JSON::PP"} //= 0;
$res->{expr_filter} = join(
"",
"do { my \$decoded; eval { \$decoded = JSON::PP->new->allow_nonref->decode($dt); 1 }; \$@ ? $dt : \$decoded }",
);
$res;
}
lib/Data/Sah/Filter/perl/Str/try_decode_json.pm view on Meta::CPAN
This rule is sometimes convenient if you want to accept unquoted string or a
data structure (encoded in JSON). This means, compared to just decoding from
JSON, you don't have to always quote your string. But beware of traps like the
bare values C<null>, C<true>, C<false> becoming undef/1/0 in Perl instead of
string literals, because they can be JSON-decoded.
=for Pod::Coverage ^(meta|filter)$
=head1 HOMEPAGE
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Section/Simple.pm view on Meta::CPAN
=head2 utf8 pragma
If you enable L<utf8> pragma in the caller's package (or the package
you're inspecting with the OO interface), the data retrieved via
C<get_data_section> is decoded, but otherwise undecoded. There's no
reliable way for this module to programmatically know whether utf8
pragma is enabled or not: it's your responsibility to handle them
correctly.
=head1 AUTHOR
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Section.pm view on Meta::CPAN
Carp::confess("bogus data section: text outside of named section")
unless defined $current;
$current_line++;
unless ($default_encoding eq 'bytes') {
my $decoded_line = eval { decode($default_encoding, $line, Encode::FB_CROAK) }
or warn "Invalid character encoding in $current, line $current_line\n";
$line = $decoded_line if defined $decoded_line;
}
$line =~ s/\A\\//;
${$template->{$current}} .= $line;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Serializer/Cookbook.pm view on Meta::CPAN
my $raw_serializer = Data::Serializer::Raw->new();
=head1 Encrypting your data
You wish to encrypt your data structure, so that it can only be decoded
by someone who shares the same key.
=head2 Solution
$serializer->secret('mysecret');
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/SimpleKV.pm view on Meta::CPAN
to call save() will overwrite previous changes.
=head1 UTF-8 SUPPORT
The module fully supports UTF-8 encoded strings for both keys and values.
All string data is properly encoded/decoded to ensure correct storage
and retrieval of international characters.
=head1 DEPENDENCIES
=over 4
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Structure/Deserialize/Auto.pm view on Meta::CPAN
$n = shift(@decoders);
my $decoder = $decoders{$n};
try {
my $structure = $decoder->($v);
if (ref($structure) eq 'HASH' || ref($structure) eq 'ARRAY') {
# warn("decoded using '$n'");
return $decoder->($v);
}
} catch {
# ignore any errors and try the next decoder, or die out at the bottom
};
view all matches for this distribution
view release on metacpan or search on metacpan
ok( has_utf8( $hash2 ), "Has utf8" );
is( has_utf8( $hash2 ), $hash2, "Has utf8" );
is( $hash2->{key1}, $hash->{key1}, "Same string" );
ok( !compare( $hash2->{key1}, $hash->{key1} ), "Different encoding" );
ok( utf8_off( $hash2 ), "Have decoded utf8" );
ok( !has_utf8( $hash2 ), "Has not utf8" );
is( $hash2->{key1}, $hash->{key1}, "Same string" );
ok( compare( $hash2->{key1}, $hash->{key1} ), "Same encoding" );
ok( utf8_on( $hash ), "Have encoded utf8" );
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/TagDB/Tag.pm view on Meta::CPAN
=head2 displaycolour
my $displaycolour = $tag->displaycolour( [ %opts ] );
Returns a colour that can be used to display the tag or C<undef>.
This will return a decoded object, most likely (but not necessarily) an instance of L<Data::URIID::Colour>.
Later versions of this module may allow to force a specific type.
B<Note:> Future versions of this method will C<die> if no value can be found.
The following universal options are supported: L</default>.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Transform/ExplicitMetadata.pm view on Meta::CPAN
descriptor number and open mode. It will first try fcntl() with F_GETFL
to determine the open mode, falling back to using FileHandle::Fmode if it's
available. Finally, it will first try re-opening the file descriptor in
read mode, then write mode.
Coderefs cannot be decoded properly. They are recreated by returning a
reference to a dummy sub that returns a message explaning the situation.
=back
=head1 SEE ALSO
view all matches for this distribution
view release on metacpan or search on metacpan
t/01_zlib.t view on Meta::CPAN
my $compressed = $filter->put( [ $teststring, Data::Transform::Meta::EOF->new() ] );
is (@$compressed, 3, "sending a string plus EOF gets the right amount of packets");
pop @$compressed; # the EOF packet doesn't go over the wire normally
my $answer = $filter->get( $compressed );
is( @$answer, 1, 'decoding those gets the correct number of packets');
is( $answer->[0], $teststring, 'the decoded string equals the original' );
}
my $stack = Data::Transform::Stackable->new( Filters =>
[
view all matches for this distribution
view release on metacpan or search on metacpan
t/json_read.t view on Meta::CPAN
use PointReadHandler;
use Test::More;
use Data::Transit;
# scalars
is_decoded_to('["~#\'",null]', undef);
is_decoded_to('["~#\'","foo"]', "foo");
is_decoded_to('["~#\'",1]', 1);
# arrays
is_decoded_to('[]', []);
is_decoded_to('["foo"]', ["foo"]);
# maps
is_decoded_to('["^ "]', {});
is_decoded_to('[["^ "]]', [{}]);
is_decoded_to('["^ ","foo",1]', {foo => 1});
is_decoded_to('[["^ ","foo",1],"bar"]', [{foo => 1}, "bar"]);
is_decoded_to('["^ ","foo",["^ ","bar",1]]', {foo => {bar => 1}});
# caching
is_decoded_to('[["^ ","foo",1,"fooo",1],["^ ","foo",1,"^0",1]]',[{foo => 1, fooo => 1}, {foo => 1, fooo => 1}]);
is_decoded_to('[["^ ","fooo",1],["^ ","^0",1]]', [{fooo => 1}, {fooo => 1}]);
# custom handlers
is_decoded_to('["~#point","2,3"]', Point->new(2,3), {point => PointReadHandler->new()});
is_decoded_to('[["~#point","2,3"],["^0","3,4"]]', [Point->new(2,3), Point->new(3,4)], {point => PointReadHandler->new()});
# types not in base perl
is_decoded_to('["^ ","~_",1]', {"" => 1});
is_decoded_to('["~#\'",true]', 1);
is_decoded_to('["~#\'",false]', 0);
is_decoded_to('["^ ","~?t",1]', {1 => 1});
is_decoded_to('["^ ","~?f",1]', {0 => 1});
is_decoded_to('["~#\'","~i123"]', 123);
is_decoded_to('["~#\'","~d123.456"]', 123.456);
done_testing();
sub is_decoded_to {
my ($json, $data, $handlers) = @_;
my $reader = Data::Transit::reader("json", handlers => $handlers);
return is_deeply($reader->read($json), $data);
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/URIID/Barcode.pm view on Meta::CPAN
my $data = $barcode->data;
Returns the data of the barcode.
The returned value might differ from the value passed to L</new> as it might have been normalised, decoded (character set), or otherwise altered.
No options are supported. However the options C<default>, and C<no_defaults> are ignored.
=head2 type
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/UUID/Concise.pm view on Meta::CPAN
use Data::UUID::Concise;
my $duc = Data::UUID::Concise->new();
my $encoded_uuid = $duc->encode((Data::UUID->new)->create);
my $decoded_uuid = $duc->decode('M55djt9tt4WoFaL68da9Ef');
$duc->alphabet('aaaaabcdefgh1230123');
$duc->alphabet; # 0123abcdefgh
=head1 ATTRIBUTES
lib/Data/UUID/Concise.pm view on Meta::CPAN
symbols.
=head2 decode
Decode a string with the appropriate set of symbols and return a
Data::UUID instance representing the decoded UUID.
=head1 FUNCTIONS
=head2 _normalize_alphabet
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/VRM/GB.pm view on Meta::CPAN
A function which takes a VRM as its first and only argument, and returns a
HASHREF with the keys C<start_date> and C<end_date>.
Each of those keys has as its value a DateTime object, truncated to the 'day'.
If the registration mark couldn't be decoded to a date, either
because it's of an unrecognised format or is using a letter prefix that is
not understood, then it will return undef.
Before comparing these dates with another DateTime, you must ensure you
truncate your DateTime to the day. If you have a time portion, you will
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Validate/Japanese.pm view on Meta::CPAN
=head1 METHODS
All methods return true or false unless otherwise stated.
All methods also expect Japanese characters that have successfully been
decoded to Perl's internal unicode format.
=head2 new()
Creates a new instance of Data::Validate::Japanese
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Visitor/Encode.pm view on Meta::CPAN
$dev->decode($encoding, \@list);
$dev->decode($encoding, \$scalar);
$dev->decode($encoding, $scalar);
$dev->decode($encoding, $object);
Returns a structure containing nodes which are decoded from the specified
encoding.
=head2 decode_utf8
$dev->decode_utf8(\%hash);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/asXML.pm view on Meta::CPAN
}
# in safe_mode decode back the xml string and compare the data structures
if ($safe_mode) {
my $xml_string = $where->toString;
my $what_decoded = eval { $self->decode($xml_string) };
die 'encoding failed '.$@.' of '.eval('use Data::Dumper; Dumper([$what, $xml_string, $what_decoded])').' failed'
if not eq_deeply($what, $what_decoded);
# set back the safe mode after all was encoded
$self->safe_mode($safe_mode);
}
lib/Data/asXML.pm view on Meta::CPAN
sub decode {
my $self = shift;
my $xml = shift;
my $pos = shift || 1;
# in safe_mode "encode+decode" the decoded data for comparing
if ($self->safe_mode) {
$self->safe_mode(0);
my $data = $self->decode($xml, $pos);
my $data_redecoded = eval { $self->decode(
$self->encode($data)->toString,
$pos,
)};
die 'redecoding failed "'.$@.'" of '.eval('use Data::Dumper; Dumper([$xml, $data, $data_redecoded])').' failed'
if not eq_deeply($data, $data_redecoded);
$self->safe_mode(1);
return $data;
}
if (not $self->{'_cur_xpath_steps'}) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DataFlow/Proc/URLRetriever.pm view on Meta::CPAN
my $url =
$self->has_baseurl
? URI->new_abs( $_, $self->baseurl )->as_string
: $_;
return $self->ua->get($url)->decoded_content;
# TODO allow ArrayRef's instead of Str, and use the other elements
# as parameters for the get() method
};
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DataStore/CAS/FS/DirCodec/Universal.pm view on Meta::CPAN
C<{ "*InvalidUTF8*": $bytes_as_codepoints }>
Any attribute which contains bytes >= 0x80 and which does not have Perl's
unicode flag set will be encoded this way, so that it comes back as it went in.
However, since filenames are intended to be human-readable, they are decoded as
unicode strings when appropriate, even if they arrived as octets which just
happened to be valid UTF-8.
=head1 METHODS
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Datahub/Factory/Indexer/Solr.pm view on Meta::CPAN
);
$response = $self->out->request($request);
if ($response->is_success) {
return decode_json($response->decoded_content);
} else {
Catmandu::HTTPError->throw({
code => $response->code,
message => $response->message,
url => $response->request->uri->as_string,
method => $response->request->method,
request_headers => [],
request_body => $response->request->content,
response_headers => [],
response_body => $response->decoded_content,
});
return undef;
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DateTime/Format/JP.pm view on Meta::CPAN
=head1 DESCRIPTION
This module is used to parse and format Japanese date and time. It is lightweight and yet versatile.
It implements 2 main methods: L</parse_datetime> and L</format_datetime> both expect and return decoded utf8 string.
You can use L<Encode> to decode and encode from perl internal utf8 representation to real utf8 and vice versa.
=head1 METHODS
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DateTime/Format/Japanese.pm view on Meta::CPAN
=head1 DESCRIPTION
This module implements a DateTime::Format module that can read Japanese
date notations and create a DateTime object, and vice versa.
All formatting methods will return a decoded utf-8 string, unless otherwise
specified explicitly via the output_encoding parameter.
All parsing methods expect a decoded utf-8 string, unless otherwise specified
explicitly via the input_encoding parameter
=head1 METHODS
=head2 new()
lib/DateTime/Format/Japanese.pm view on Meta::CPAN
This function will parse a Japanese date/time string and convert it to a
DateTime object. If the parsing is unsuccessful, it will croak.
Note that if you didn't provide a input_encoding parameter, the given
string is assumed to be decoded utf-8.
This function should be able to parse almost all of the common Japanese
date notations, whether they are written using ascii numerals, double byte
numerals, and kanji numerals. The date components (year, month, day or
era name, era year, month, day) must be present in the string. The time
view all matches for this distribution
view release on metacpan or search on metacpan
script/dpkg-scanpmpackages view on Meta::CPAN
my $response = $ua->get($url);
die 'failed to fetch '.$url.' - '.$response->status_line
if (not $response->is_success);
IO::Any->spew([ $filename ], $response->decoded_content);
return;
}
sub _trim {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Debian/Snapshot.pm view on Meta::CPAN
$url = $self->url . $url;
my $response = $self->user_agent->get($url, @_);
die $response->status_line unless $response->is_success;
return $response->decoded_content;
}
sub _get_json {
my $self = shift;
my $json = $self->_get(@_);
view all matches for this distribution
view release on metacpan or search on metacpan
ex/live-test.pl view on Meta::CPAN
my $url = "http://api.textcaptcha.com/$key";
while (1) {
my $res = $ua->get($url);
next unless $res->is_success;
my $content = $res->decoded_content;
my ($q) = $content =~ m[<question>(.*?)</question>];
decode_entities($q);
my $a = decaptcha($q) // '';
my $md5 = md5_hex $a;
view all matches for this distribution
view release on metacpan or search on metacpan
Decode::Source makes it possible to write perl programs in any script or
encoding supported by the C<Encode> module. Variable names can contain
non-ASCII characters, just as when you use the C<use utf8> pragma. All
theese characters, both in identifiers and string literals, will be
decoded to perl's internal utf-8 form, before execution.
The syntax are similar to C<use utf8> and C<no utf8>, but Decode::Source
also takes an optional argument with source encoding. This argument can be
any argument that C<Encode>'s C<decode> function accept as a valid
encoding. See also L<Encode>.
view all matches for this distribution
view release on metacpan or search on metacpan
}
}
void from_to_cb( pp_func pf, SV * data){
int ret_list_size;
SV *decoded_sv;
dSP;
ENTER;
SAVETMPS;
if ( ! pf->fastinit ){
SPAGAIN;
if (ret_list_size != 1){
croak( "A big trouble");
}
decoded_sv = POPs;
PUTBACK;
PUSHMARK(SP);
XPUSHs( pf->argv[1] );
XPUSHs( decoded_sv );
PUTBACK;
if ( pf->fastinit == 1 ){
ret_list_size = call_sv( (SV *) pf->meth2, G_SCALAR);
}
SPAGAIN;
if (ret_list_size != 1){
croak( "A big trouble");
}
decoded_sv = POPs;
sv_setsv( data , decoded_sv );
PUTBACK;
FREETMPS;
LEAVE;
}
void from_to_cb_00( pp_func pf, SV * data){
int ret_list_size;
SV *decoded_sv;
dSP;
ENTER;
SAVETMPS;
PUSHMARK(SP);
ret_list_size = call_method("decode", G_SCALAR);
SPAGAIN;
if (ret_list_size != 1){
croak( "A big trouble");
}
decoded_sv = POPs;
PUTBACK;
PUSHMARK(SP);
XPUSHs( pf->argv[1] );
XPUSHs( decoded_sv );
PUTBACK;
ret_list_size = call_method("encode", G_SCALAR);
SPAGAIN;
if (ret_list_size != 1){
croak( "A big trouble");
}
decoded_sv = POPs;
sv_setsv( data , decoded_sv );
PUTBACK;
FREETMPS;
LEAVE;
}
view all matches for this distribution
view release on metacpan or search on metacpan
DC/MapWidget.pm view on Meta::CPAN
print "getting map revision for $mapname...\n";
# try to get the most recent head revision, what a hack,
# this should have been returned while downloading *sigh*
my $log = (DC::lwp_check $ua->get ("$editsup->{cvs_root}/$mapname?view=log&logsort=rev"))->decoded_content;
if ($log =~ /\?rev=(\d+\.\d+)"/) {
my $rev = $1;
print "downloading revision $rev...\n";
my $map = (DC::lwp_check $ua->get ("$editsup->{cvs_root}/$mapname?rev=$rev"))->decoded_content;
my $meta = {
%$editsup,
path => $mapname,
revision => $rev,
DC/MapWidget.pm view on Meta::CPAN
# if ($res->is_error) {
# # fatal condition
# warn $res->status_line;
# } else {
# # script replies are marked as {{..}}
# my @msgs = $res->decoded_content =~ m/\{\{(.*?)\}\}/g;
# warn map "$_\n", @msgs;
# }
} else {
die "viewvc parse error, unable to detect revision\n";
}
view all matches for this distribution