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
view release on metacpan or search on metacpan
DB/MIME/Base64.pm view on Meta::CPAN
=head1 SYNOPSIS
use DB::MIME::Base64::Perl;
$encoded = encode_base64('Aladdin:open sesame');
$decoded = decode_base64($encoded);
=head1 DESCRIPTION
This module provide the same interface as C<DB::MIME::Base64>, but these
functions are implemented in pure perl.
DB/MIME/Base64.pm view on Meta::CPAN
=item decode_base64($str)
Decode a base64 string by calling the decode_base64() function. This
function takes a single argument which is the string to decode and
returns the decoded data.
Any character not part of the 65-character base64 subset is
silently ignored. Characters occurring after a '=' padding character
are never decoded.
=back
=head1 COPYRIGHT
view all matches for this distribution
view release on metacpan or search on metacpan
bin/perlbrewise-spec view on Meta::CPAN
codeset range. Neither of these flags conflict with each other, although
some combinations make less sense than others.
Care has been taken to make all flags symmetrical with respect to
C<encode> and C<decode>, that is, texts encoded with any combination of
these flag values will be correctly decoded when the same flags are used
- in general, if you use different flag settings while encoding vs. when
decoding you likely have a bug somewhere.
Below comes a verbose discussion of these flags. Note that a "codeset" is
simply an abstract set of character-codepoint pairs, while an encoding
bin/perlbrewise-spec view on Meta::CPAN
=item C<utf8> flag disabled
When C<utf8> is disabled (the default), then C<encode>/C<decode> generate
and expect Unicode strings, that is, characters with high ordinal Unicode
values (> 255) will be encoded as such characters, and likewise such
characters are decoded as-is, no changes to them will be done, except
"(re-)interpreting" them as Unicode codepoints or Unicode characters,
respectively (to Perl, these are the same thing in strings unless you do
funny/weird/dumb stuff).
This is useful when you want to do the encoding yourself (e.g. when you
bin/perlbrewise-spec view on Meta::CPAN
$json =~ s/"__proto__"\s*:/"__proto__renamed":/g;
This works because C<__proto__> is not valid outside of strings, so every
occurrence of C<"__proto__"\s*:> must be a string used as property name.
Unicode non-characters between U+FFFD and U+10FFFF are decoded either
to the recommended U+FFFD REPLACEMENT CHARACTER (see Unicode PR #121:
Recommended Practice for Replacement Characters), or in the binary or
relaxed mode left as is, keeping the illegal non-characters as before.
Raw non-Unicode characters outside the valid unicode range fail now to
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Devel/IPerl/Display/Role/MIMESource.pm view on Meta::CPAN
return $data;
} elsif( $self->uri ) {
my $ua = LWP::UserAgent->new();
my $response = $ua->get( $self->uri );
die "Could not retrieve data" unless $response->is_success;
my $data = $response->decoded_content;
return $data;
}
die "No data to build display"; # TODO create exception class
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Devel/PatchPerl/Hints.pm view on Meta::CPAN
=item C<hint_file>
Takes an optional argument which is the OS name ( as would be returned by C<$^O> ).
By default it will use C<$^O>.
In a scalar context, Will return the decoded content of the C<hints> file suitable for writing straight to a
file handle or undef list if there isn't an applicable C<hints> file for the given or derived
OS.
If called in a list context, will return a list, the first item will be the name of the C<hints> file that
will need to be amended, the second item will be a string with the decoded content of the C<hints> file suitable
for writing straight to a file handle. Otherwise an empty list will be returned.
=item C<hints>
Takes no arguments, returns a list of OS names for which there are C<hints> files.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Devel/QuickCover/Report.pm view on Meta::CPAN
sub load {
my ($self, $file) = @_;
my $data = path($file)->slurp_raw;
my $decoded = Sereal::decode_sereal($data);
if (exists $decoded->{files}) {
$self->{data} = $decoded;
} else {
$self->{data} = {
files => $decoded,
metadata => {},
};
}
$self->{changes} = 0;
}
lib/Devel/QuickCover/Report.pm view on Meta::CPAN
sub merge {
my ($self, $file) = @_;
my $json = path($file)->slurp;
my $decoded = decode_json($json);
my $files = $self->{data}{files};
my $subs = $self->{data}{subs};
# I don't think custom merging functions are needed
@{$self->{data}{metadata}}{keys %{$decoded->{metadata}}} =
values %{$decoded->{metadata}};
for my $name (keys %{$decoded->{files}}) {
my $coverage = $decoded->{files}{$name};
for my $line (@{$coverage->{covered}}) {
$files->{$name}->{$line}++;
}
for my $line (@{$coverage->{present}}) {
$files->{$name}->{$line} //= 0;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Devel/StackTrace/AsHTML.pm view on Meta::CPAN
no warnings 'qw';
my %enc = qw( & & > > < < " " ' ' );
# NOTE: because we don't know which encoding $str is in, or even if
# $str is a wide character (decoded strings), we just leave the low
# bits, including latin-1 range and encode everything higher as HTML
# entities. I know this is NOT always correct, but should mostly work
# in case $str is encoded in utf-8 bytes or wide chars. This is a
# necessary workaround since we're rendering someone else's code which
# we can't enforce string encodings.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Devel/StackTrace/AsHTMLExtended.pm view on Meta::CPAN
no warnings 'qw';
my %enc = qw( & & > > < < " " ' ' );
# NOTE: because we don't know which encoding $str is in, or even if
# $str is a wide character (decoded strings), we just leave the low
# bits, including latin-1 range and encode everything higher as HTML
# entities. I know this is NOT always correct, but should mostly work
# in case $str is encoded in utf-8 bytes or wide chars. This is a
# necessary workaround since we're rendering someone else's code which
# we can't enforce string encodings.
view all matches for this distribution
view release on metacpan or search on metacpan
t/02-bad-utf8.t view on Meta::CPAN
use Devel::StackTrace;
# This should be invalid UTF8
my $raw_bad = do { use bytes; chr(0xED) . chr(0xA1) . chr(0xBA) };
my $decoded = Encode::decode( 'utf8' => $raw_bad );
my $trace = foo($decoded);
my $string = eval { $trace->as_string() };
my $e = $@;
is(
view all matches for this distribution