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

From: Christoph Moench-Tegeder <cmt(at)burggraben(dot)net>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Perl DBI converts UTF-8 again to UTF-8 before sending it to the server
Date: 2019-10-04 14:29:32
Message-ID: 20191004142932.GA2532@elch.exwg.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

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

Regards,
Christoph

--
Spare Space

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dmitry Bogatov 2019-10-04 14:35:51 Unexpected plan width with foreign data wrapper
Previous Message Thomas Kellerer 2019-10-04 14:21:26 Re: Postgres 12: backend crashes when creating non-deterministic collation