Re: Perl DBI converts UTF-8 again to UTF-8 before sending it to the server

2019-10-12 Thread Daniel Verite
Christoph Moench-Tegeder wrote: > And then it doesn't know that your terminal expects UTF-8 (perl > just dumps the binary string here), because you didn't tell it: > "binmode(STDOUT, ':encoding(utf8)')" would fix that. Or use perl -C, so that it gets that from the environment. From http

Re: Perl DBI converts UTF-8 again to UTF-8 before sending it to the server

2019-10-12 Thread Christoph Moench-Tegeder
## Matthias Apitz (g...@unixarea.de): > but when I now fetch the first row with: > >@row = $sth->fetchrow_array; >$HexStr = unpack("H*", $row[0]); >print "HexStr: " . $HexStr . "\n"; >print "$row[0]\n"; > > The resulting column contains ISO data: As expected: https://perldoc.per

Re: Perl DBI converts UTF-8 again to UTF-8 before sending it to the server

2019-10-11 Thread Matthias Apitz
Christoph, May I come back to the UTF-8 problem, but now for the reading aspect: I connect to the PG server with: $dbh = DBI->connect($PGDB, $PGDB_USER, $PGDB_PASS, { pg_utf8_flag => 1, pg_enable_utf8 => 1, AutoCommit => 0, RaiseError => 0, PrintError => 0, }

Re: Perl DBI converts UTF-8 again to UTF-8 before sending it to the server

2019-10-04 Thread Christoph Moench-Tegeder
## Matthias Apitz (g...@unixarea.de): > my $text = "ä \xc3\xa4"; That will only work if you remove "use utf8". And then other stuff may break. Regards, Christoph -- Spare Space

Re: Perl DBI converts UTF-8 again to UTF-8 before sending it to the server

2019-10-04 Thread Matthias Apitz
El día viernes, octubre 04, 2019 a las 04:29:32p. m. +0200, Christoph Moench-Tegeder escribió: > ## Matthias Apitz (g...@unixarea.de): > > > my $text = "\xc3\xa4"; > > print "text: ".$text."\n"; > > Your output is lying to you: > you need a binmode(STDOUT, ':encoding(utf8)'), which will make th

Re: Perl DBI converts UTF-8 again to UTF-8 before sending it to the server

2019-10-04 Thread Christoph Moench-Tegeder
## Matthias Apitz (g...@unixarea.de): > my $text = "\xc3\xa4"; > print "text: ".$text."\n"; Your output is lying to you: you need a binmode(STDOUT, ':encoding(utf8)'), which will make this print "ä", and a utf8::decode($text), after which you get "ä". And when you pass that $text through DBD::Pg

Perl DBI converts UTF-8 again to UTF-8 before sending it to the server

2019-10-04 Thread Matthias Apitz
Hello, We're facing the problem that UTF-8 data to be INSERT'ed into a CHAR column is converted again to UTF-8, assuming it's ISO. I have here a small Perl program which can be used for testing: #!/usr/local/bin/perl use utf8; my $PGDB = 'dbi:Pg:dbname=newsisis;host=127.0.0.1'; my $PGDB_