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
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
lib/Encode/Safename.pm view on Meta::CPAN
use Encode qw(decode encode);
use Encode::Safename;
$encoded = encode('safename', 'Foo Bar Baz.txt');
# $encoded is now '{f}oo_{b}ar_{b}az.txt'
$decoded = decode('safename', $encoded);
# $decoded is now 'Foo Bar Baz.txt'
=head1 DESCRIPTION
A filename is encoded as follows:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Decode/ARGV.pm view on Meta::CPAN
=head1 DESCRIPTION
This module provides simple in-place decoding of command-line arguments in the global array
L<@ARGV|perlvar/"@ARGV">. As with most input and output, command-line arguments are provided to the
script in bytes, and must be decoded to characters before performing string operations like
C<length> or regex matches.
The C<-CA> switch for Perl performs a similar function, but this has some deficiencies. It assumes
via the C<:utf8> internal layer that the arguments are valid UTF-8 bytes, ignoring invalid Unicode,
and even resulting in malformed strings if the bytes do not happen to be well-formed UTF-8. This
view all matches for this distribution
view release on metacpan or search on metacpan
t/01-decode.t view on Meta::CPAN
is $wechsler->decode( 'xq4_27deee6' ),
".**....
**.****
.******
..****.
", 'xq4_27deee6 decoded correctly';
is $wechsler->decode( 'xs31_0ca178b96z69d1d96' ),
"...**.**.
..*.*.*.*
.*..*...*
t/01-decode.t view on Meta::CPAN
.........
.*****...
*.....*..
*.*.*.*..
.**.**...
", 'xs31_0ca178b96z69d1d96 decoded correctly';
is $wechsler->decode( 'xp30_w33z8kqrqk8zzzx33' ),
"..**...
..**...
.......
t/01-decode.t view on Meta::CPAN
.......
.......
...**..
...**..
.......
", 'xp30_w33z8kqrqk8zzzx33 decoded correctly';
is $wechsler->decode( 'xp2_31a08zy0123cko' ),
"**........
*.*.......
..........
t/01-decode.t view on Meta::CPAN
....*.*...
.....**...
.......**.
.......*.*
........**
", 'xp2_31a08zy0123cko decoded correctly';
#is $wechsler->decode( 'xp30_ccx8k2s3yagzy3103yaheha4xcczyk1' ),
#"
#", 'xp30_ccx8k2s3yagzy3103yaheha4xcczyk1 decoded correctly';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Encode/ZapCP1252.pm view on Meta::CPAN
fix_cp1252; # Modify $_ in-place.
my $zapped = zap_cp1252; # Copy $_ and return zapped
my $fixed = zap_cp1252; # Copy $_ and return fixed
In Perl 5.8.8 and higher, the conversion will work even when the string is
decoded to Perl's internal form (usually via C<decode 'ISO-8859-1', $text>) or
the string is encoded (and thus simply processed by Perl as a series of
bytes). The conversion will even work on a string that has not been decoded
but has had its C<utf8> flag flipped anyway (usually by an injudicious use of
C<Encode::_utf8_on()>. This is to enable the highest possible likelihood of
removing those CP1252 gremlins no matter what kind of processing has already
been executed on the string.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Encoding/BER.pm view on Meta::CPAN
Unlike many other BER encoder/decoders, this module uses tree structured data
as the interface to/from the encoder/decoder.
The decoder does not require any form of template or description of the
data to be decoded. Given arbitrary BER encoded data, the decoder produces
a tree shaped perl data structure from it.
The encoder takes a perl data structure and produces a BER encoding from it.
=head1 METHODS
lib/Encoding/BER.pm view on Meta::CPAN
# example: warn for warnings
warn => sub{ warn "how odd! $_[1]\n" }
=item decoded_callback
coderef called for every element decoded. will be called with 2 parameters,
the Encoding::BER object, and the decoded data. [see DECODED DATA]
# example: bless decoded results into a useful class
decoded_callback => sub{ bless $_[1], MyBER::Result }
=item debug
boolean. if true, large amounts of useless gibberish will be sent to stderr regarding
the encoding or decoding process.
lib/Encoding/BER.pm view on Meta::CPAN
$result->{type} = $typdat;
$result->{tagnum} = $tagnum;
$result->{identval} = $typval;
if( my $c = $me->{decoded_callback} ){
$result = $c->( $me, $result ) || $result; # make sure the brain hasn't fallen out
}
return( $result, $tlen );
}
view all matches for this distribution
view release on metacpan or search on metacpan
%% @doc Yet another JSON (RFC 4627) library for Erlang. mochijson2 works
%% with binaries as strings, arrays as lists (without an {array, _})
%% wrapper and it only knows how to decode UTF-8 (and ASCII).
%%
%% JSON terms are decoded as follows (javascript -> erlang):
%% <ul>
%% <li>{"key": "value"} ->
%% {struct, [{<<"key">>, <<"value">>}]}</li>
%% <li>["array", 123, 12.34, true, false, null] ->
%% [<<"array">>, 123, 12.34, true, false, null]
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Etcd3/Role/Actions.pm view on Meta::CPAN
return $self;
}
=head2 get_value
returns single decoded value or the first.
=cut
sub get_value {
my ($self) = @_;
lib/Etcd3/Role/Actions.pm view on Meta::CPAN
'value' => 'bar',
'create_revision' => '3',
'key' => 'foo0'
}
where key and value have been decoded for your pleasure.
=cut
sub all {
my ($self) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Ethereum/RPC/Contract.pm view on Meta::CPAN
has max_priority_fee_per_gas => (is => 'rw');
has gas => (is => 'rw');
has contract_decoded => (
is => 'rw',
default => sub { {} },
);
=head2 BUILD
lib/Ethereum/RPC/Contract.pm view on Meta::CPAN
=cut
sub BUILD {
my ($self) = @_;
my @decoded_json = @{decode_json($self->contract_abi // "[]")};
for my $json_input (@decoded_json) {
if ($json_input->{type} =~ /^function|event|constructor$/) {
push(@{$self->contract_decoded->{$json_input->{name} // $json_input->{type}}}, $json_input->{inputs});
}
}
unless ($self->contract_decoded->{constructor}) {
push(@{$self->contract_decoded->{constructor}}, []);
}
return;
}
lib/Ethereum/RPC/Contract.pm view on Meta::CPAN
=cut
sub get_function_id {
my ($self, $function_name, $params_size) = @_;
my @inputs = @{$self->contract_decoded->{$function_name}};
my $selected_data = first { (not $_ and not $params_size) or ($params_size and scalar @{$_} == $params_size) } @inputs;
$function_name .= sprintf("(%s)", join(",", map { $_->{type} } grep { $_->{type} } @$selected_data));
lib/Ethereum/RPC/Contract.pm view on Meta::CPAN
=cut
sub encode {
my ($self, $function_name, $params) = @_;
my $inputs = $self->contract_decoded->{$function_name}->[0];
# no inputs
return "" unless $inputs;
my $offset = $self->get_function_offset($inputs);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Eve/Json.pm view on Meta::CPAN
use Eve::Json;
my $json = Eve::Json->new();
my $json_string = $json->encode(reference => $reference);
my $decoded_reference = $json->decode(string => $json_string);
=head1 DESCRIPTION
The B<Eve::Json> class adapts the functionality of the JSON::XS
module to provide JSON encoding and decoding features service.
lib/Eve/Json.pm view on Meta::CPAN
return $result;
}
=head2 B<decode()>
Decodes a JSON string and returns a reference to its decoded contents.
=head3 Arguments
=over 4
view all matches for this distribution
view release on metacpan or search on metacpan
lib/EveOnline/Api.pm view on Meta::CPAN
die "Error: " . $res->status_line . "\n";
}
my $text = $res->decoded_content;
return $text;
}
1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Event/RPC/Message/Negotiate.pm view on Meta::CPAN
sub get_storable_fallback_ok { $STORABLE_FALLBACK_OK }
sub set_storable_fallback_ok { $STORABLE_FALLBACK_OK = $_[1] }
sub encode_message {
my $self = shift;
my ($decoded) = @_;
my $ok = $decoded->{ok} || "";
my $msg = $decoded->{msg} || "";
my $cmd = $decoded->{cmd} || "";
s,/\d/,,g for ( $ok, $msg, $cmd );
return "/0/E:R:M:N/1/$ok/2/$msg/3/$cmd/0/";
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Evented/API/Engine.pm view on Meta::CPAN
$api->Log($mod_name, "Load FAILED: JSON parsing of $path failed: $@");
$api->Debug($mod_name, "JSON text: $slurp");
return;
}
# JSON was decoded successfully at this point.
# developer mode is disabled, so return the manifest.
elsif (!$api->{developer}) {
$use_manifest++;
}
# JSON was decoded successfully, but we're in developer mode.
# check the modification times. only use the manifest if the module's
# main package has not been modified since the manifest was written.
else {
my $pkg_modified = (stat "$mod_dir/$mod_last_name.pm" )[9];
my $man_modified = (stat "$mod_dir/$mod_last_name.json")[9];
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Excel/PowerPivot/Utils.pm view on Meta::CPAN
If none is supplied, a simple logger is automatically created from L<Log::Dispatch>.
=item UTF8
A boolean flag for setting the L<Win32::OLE> codepoint option to UTF8, so that
strings are properly encoded/decoded between Perl and the OLE server.
It is highly recommended to I<systematically set this option to true>, since
this module is mostly used together with L<YAML>, which uses UTF8 encoding.
This option will automatically trigger C<< Win32::OLE->Option(CP => CP_UTF8) >>
at object construction time, and will set it back to the previous value at object
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Excel/Writer/XLSX/Worksheet.pm view on Meta::CPAN
###############################################################################
#
# _get_range_data
#
# Returns a range of data from the worksheet _table to be used in chart
# cached data. Strings are returned as SST ids and decoded in the workbook.
# Return undefs for data that doesn't exist since Excel can chart series
# with data missing.
#
sub _get_range_data {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Exception/Stringy.pm view on Meta::CPAN
my $value = $exception->$xfield('field_name');
$exception->$xfield(field_name => $value);
Set or get the given field. If the value contains one of the following
caracters, then it is transparently base64 encoded and decoded.
The list of forbidden caracters are:
=over
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Exercises/API.pm view on Meta::CPAN
}
sub _request( $self, $uri ) {
my $response = $self->ua->get($uri);
if ( $response->is_success ) {
return decode_json( $response->decoded_content );
}
else {
my $code = $response->code;
confess "Exercises API status code ($code)\n"
. "Error: "
view all matches for this distribution
view release on metacpan or search on metacpan
public/javascripts/vendor/backbone/backbone.js view on Meta::CPAN
// The default interval to poll for hash changes, if necessary, is
// twenty times a second.
interval: 50,
// Gets the true hash value. Cannot use location.hash directly due to bug
// in Firefox where location.hash will always be decoded.
getHash: function(windowOverride) {
var loc = windowOverride ? windowOverride.location : window.location;
var match = loc.href.match(/#(.*)$/);
return match ? match[1] : '';
},
view all matches for this distribution
view release on metacpan or search on metacpan
bundled/JSON-PP/JSON/PP.pm view on Meta::CPAN
This section supposes that your perl vresion is 5.8 or later.
If you know a JSON text from an outer world - a network, a file content, and so on,
is encoded in UTF-8, you should use C<decode_json> or C<JSON> module object
with C<utf8> enable. And the decoded result will contain UNICODE characters.
# from network
my $json = JSON::PP->new->utf8;
my $json_text = CGI->new->param( 'json_data' );
my $perl_scalar = $json->decode( $json_text );
view all matches for this distribution
view release on metacpan or search on metacpan
lib/perlxstut.pod view on Meta::CPAN
=over 4
=item *
The INIT: directive contains code that will be placed immediately after
the argument stack is decoded. C does not allow variable declarations at
arbitrary locations inside a function,
so this is usually the best way to declare local variables needed by the XSUB.
(Alternatively, one could put the whole C<PPCODE:> section into braces, and
put these declarations on top.)
view all matches for this distribution
view release on metacpan or search on metacpan
t/02-extism.t view on Meta::CPAN
ok($fplugin);
my $hello = "Hello, World!";
$highlevel[0] = $fplugin->call("count_vowels", $hello);
$highlevel[1] = $fplugin->call("count_vowels", $hello);
}
my @decoded = map {decode_json $_} @highlevel;
ok($decoded[0]{count} == 3);
ok($decoded[0]{count} == $decoded[1]{count});
ok($decoded[0]{total} == 3);
ok($decoded[1]{total} == 6);
# Verify both sets of results are the same
is($highlevel[0], $lowlevel[0]);
is($highlevel[1], $lowlevel[1]);
view all matches for this distribution
view release on metacpan or search on metacpan
$h->header($key => $value);
}
my $r = HTTP::Response->new(200, 'OK', $h, $body);
ok($h->content_encoding() eq 'gzip');
$body = $r->decoded_content();
if($^O eq 'MSWin32') {
ok($body =~ /\\web\\English\\test4.cgi\\.+\.html"/m);
} else {
ok($body =~ /"\/web\/English\/test4.cgi\/.+\.html"/m);
}
view all matches for this distribution