Weird interaction between Gtk3, JSON::PP and locale



If I have, say the de_DE.UTF-8 locale installed, and run the code below with

LC_ALL=de_DE.UTF-8 perl gtk3_application_json.pl

then when it exits, the following (illegal - decimal comma) JSON is printed:

{
   "real_number" : 0,05
}

If I change the "use Gtk3" line to "use Gtk3 -init", then the correct -
decimal point JSON is printed:

{
   "real_number" : 0.05
}

What is going on?

Regards

Jeff

#!/usr/bin/perl

package MyApp;

BEGIN {
  use Glib::Object::Introspection;
  Glib::Object::Introspection->setup(
    basename => 'Gio',
    version => '2.0',
    package => 'Glib::IO');
}

use strict;
use warnings;

use JSON::PP;
use Gtk3;
use Glib qw/TRUE FALSE/;

use Glib::Object::Subclass qw/Gtk3::Application/;

sub STARTUP {
    my ($app) = @_;
    print "in startup\n";
    return $app->SUPER::STARTUP ();
}

sub ACTIVATE {
    my ($app) = @_;
    print "in activate\n";
    my $window = Gtk3::ApplicationWindow->new ($app);
    $window->set_title ('Welcome to GNOME');
    $window->set_default_size (200, 200);
    $window->signal_connect ('delete_event' => sub {$app->quit()});
    $window->show_all ();
    return $app->SUPER::ACTIVATE ();
}

sub OPEN {
    my ($app, $files, $nfiles, $arg3) = @_;
    print "in open\n";
    use Data::Dumper;
    print Dumper($files, $nfiles, $arg3);
    for my $file (@$files) {
        print $file->get_basename(), "\n";
    }
}

sub SHUTDOWN {
    my ($app) = @_;
    print "in shutdown\n";
    my %hashref = ( real_number => 0.05 );
    my $conf = JSON::PP->new->ascii;
    $conf = $conf->pretty->allow_nonref;
    $conf = $conf->canonical;
    print $conf->encode(\%hashref);
    return $app->SUPER::SHUTDOWN ();
}

package main;

my $app = MyApp->new(
        application_id => 'app.test',
        flags => 'handles-open');
exit $app->run([$0, @ARGV]);

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]