in reply to PgPP invalid byte seqnence for encoding UTF8
Hi,
what does the psql driver expect as input? A UTF-8 encoded string?
When you do the following:
you see, that after decoding JSON you get probably strings which are marked as unicode. As soon as you are using "output" of these strings (a database is one of the many output channels) you have to asked which encoding is expected. That means: If psql expects UTF-8 encoding you have to encode the string appropriately with Encode::encode('UTF-8', $string);#!/usr/bin/perl use warnings; use strict; use Data::Dumper; use JSON; my $json = q({"my": "En d\u00e9mocratie, on a le droit d'avoir tort"}) +; my $perl = decode_json $json; my $flag_utf8 = utf8::is_utf8($perl->{'my'}) ? 1 : 0; print "is unicode: $flag_utf8\n"; print Dumper($perl), "\n";
McA
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: PgPP invalid byte seqnence for encoding UTF8
by cormanaz (Deacon) on Mar 24, 2013 at 16:22 UTC | |
by McA (Priest) on Mar 24, 2013 at 18:07 UTC | |
by cormanaz (Deacon) on Mar 24, 2013 at 18:54 UTC | |
by McA (Priest) on Mar 24, 2013 at 18:58 UTC | |
by cormanaz (Deacon) on Mar 24, 2013 at 19:10 UTC |