The JSON module claims to expect UTF-8, but it doesn't seem to like it.
I get the same "Wide character in subroutine entry" error for external
UTF-8 data files read { open(FH, '<:encoding(UTF-8)', $jsonfile) },
UTF-8 included in strings in "use utf8;" source, and \x{} escapes for
Unicode characters.
:r! cat /tmp/test-json
#!/usr/bin/perl -w
use JSON;
use strict;
use vars qw( $json $data );
# begin flailing for a fix to "Wide character in subroutine entry" {
use diagnostics;
use feature 'unicode_strings';
use utf8;
binmode STDIN, ':utf8';
binmode STDERR, ':utf8';
binmode STDOUT, ':utf8';
no warnings 'utf8';
# } end flailing
$json = qq![
{
"unicode": "U+2512",
"highbit": "\x{2512}"
}
]!;
$data = decode_json $json;
__END__
:r! env -i /usr/local/bin/perl5.14.1 /tmp/test-json
Wide character in subroutine entry at /tmp/test-json line 23 (#1)
(S utf8) Perl met a wide character (>255) when it wasn't expecting
one. This warning is by default on for I/O (like print). The easiest
way to quiet this warning is simply to add the :utf8 layer to the
output, e.g. binmode STDOUT, ':utf8'. Another way to turn off the
warning is to add no warnings 'utf8'; but that is often closer to
cheating. In general, you are supposed to explicitly mark the
filehandle with an encoding, see open and "binmode" in perlfunc.
Uncaught exception from user code:
Wide character in subroutine entry at /tmp/test-json line 23.
at /tmp/test-json line 23
:r! env -i /usr/local/bin/perl5.20.2 /tmp/test-json
Use of uninitialized value $^WARNING_BITS in bitwise xor (^) at /usr/local/lib/perl5/site_perl/5.14.1/common/
sense.pm line 237.
Use of uninitialized value $^WARNING_BITS in bitwise xor (^) at /usr/local/lib/perl5/site_perl/5.14.1/common/
sense.pm line 237.
Wide character in subroutine entry at /tmp/test-json line 23 (#1)
(S utf8) Perl met a wide character (>255) when it wasn't expecting
one. This warning is by default on for I/O (like print). The easiest
way to quiet this warning is simply to add the :utf8 layer to the
output, e.g. binmode STDOUT, ':utf8'. Another way to turn off the
warning is to add no warnings 'utf8'; but that is often closer to
cheating. In general, you are supposed to explicitly mark the
filehandle with an encoding, see open and "binmode" in perlfunc.
Uncaught exception from user code:
Wide character in subroutine entry at /tmp/test-json line 23.
:r! /usr/local/bin/perl5.20.2 -v
This is perl 5, version 20, subversion 2 (v5.20.2) built for i386-netbsd-thread-multi
Copyright 1987-2015, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at
http://www.perl.org/, the Perl Home Page.
That's running on the Panix hosts, where I have my personal webspace. Panix
keeps multiple versions of perl around, currently nine between 5.00403
and 5.20.2. I get the same results on Ubuntu (12.04.4) with the packaged
perl:
This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux-gnu-thread-multi
(with 57 registered patches, see perl -V for more detail)
$ /usr/bin/perl test-json
Wide character in subroutine entry at test-json line 21 (#1)
(S utf8) Perl met a wide character (>255) when it wasn't expecting
one. This warning is by default on for I/O (like print). The easiest
way to quiet this warning is simply to add the :utf8 layer to the
output, e.g. binmode STDOUT, ':utf8'. Another way to turn off the
warning is to add no warnings 'utf8'; but that is often closer to
cheating. In general, you are supposed to explicitly mark the
filehandle with an encoding, see open and "binmode" in perlfunc.
Uncaught exception from user code:
Wide character in subroutine entry at test-json line 21.
at test-json line 21
$
(That test-json doesn't have the two "flailing" comments, so different
line numbers.)
What am I missing here?
Elijah
------
has other code using the JSON module that just seems to work