Search Postgresql Archives

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

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

 



El día viernes, octubre 04, 2019 a las 04:29:32p. m. +0200, Christoph Moench-Tegeder escribió:

> ## Matthias Apitz (guru@xxxxxxxxxxx):
> 
> > 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, it will still be an "ä". And when you
> change $text to "ä", it still works. Most other combinations will
> either fail with "\xc3\xa4" or "ä".

Thanks, but:

...
my $text = "ä \xc3\xa4";
print "text before STDOUT set to UTF-8: ".$text."\n";
binmode(STDOUT, ':encoding(utf8)');
print "text after STDOUT set to UTF-8: ".$text."\n";
utf8::decode($text);
print "text after utf8::decode(\$text): ".$text."\n";
$sth->execute($text, 1) or die $sth->errstr, "\n";

gives:


./utf8.pl
text before STDOUT set to UTF-8: ä
text after STDOUT set to UTF-8: ä ä
text after utf8::decode($text): ä ä
printf "select tstchar25::bytea from dbctest ;\n" | psql -Usisis -dnewsisis
                         tstchar25
------------------------------------------------------------
 \xc3a420c383c2a4202020202020202020202020202020202020202020
(1 Zeile)

> Welcome to modern perl's handling of utf8. Cue "Everything is Fine" meme.

Seems so :-(

	matthias


-- 
Matthias Apitz, ✉ guru@xxxxxxxxxxx, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub

3. Oktober! Wir gratulieren! Der Berliner Fernsehturm wird 50 
aus: https://www.jungewelt.de/2019/10-02/index.php

Attachment: signature.asc
Description: PGP signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux