JSON-MultiValueOrdered
view release on metacpan or search on metacpan
lib/JSON/Tiny/Subclassable.pm view on Meta::CPAN
sub decode {
my ($self, $bytes) = @_;
# Cleanup
$self->error(undef);
# Missing input
$self->error('Missing or empty input') and return undef unless $bytes; ## no critic (undef)
# Remove BOM
$bytes =~ s/^(?:\357\273\277|\377\376\0\0|\0\0\376\377|\376\377|\377\376)//g;
# Wide characters
$self->error('Wide character in input') and return undef ## no critic (undef)
unless utf8::downgrade($bytes, 1);
# Detect and decode Unicode
my $encoding = 'UTF-8';
$bytes =~ $UTF_PATTERNS->{$_} and $encoding = $_ for keys %$UTF_PATTERNS;
( run in 0.863 second using v1.01-cache-2.11-cpan-e9daa2b36ef )