Do you know where your variables are? | |
PerlMonks |
DBD::pg considers input and output ISO8859by apz (Initiate) |
on Sep 25, 2018 at 18:22 UTC ( [id://1222990]=perlquestion: print w/replies, xml ) | Need Help?? |
apz has asked for the wisdom of the Perl Monks concerning the following question: Dear monks, Many moons ago I wrote a Perl script for data entry into PostgreSQL database over a web GUI. The system ran on Ubuntu server 14.04 and it never had any issues with encoding. What was posted from a web form had encoding that would make it readable from PostgreSQL's shell client. The system however needs to be upgraded to 18.04 and here's where the issue arose. Now all the output I get from DBD:Pg is in ISO8859. The database itself is in UTF8, the server and client both report UTF8 as encoding. I can run queries interactively or from one shot shell commands and receive the data in correct encoding. But not if used from DBI. I installed a fresh 18.04 installation to debug the issue and the problem persists. Here's an example of the issue: First creation of a demo table:
So far so good. If the last select query is redirected to a text file, examining it with a hex editor reveals it's UTF8, file-command agrees. Next we try the same with DBI: Instead of replicating what came out in PostgreSQL's interactive shell, we get:
If redirected to a text file, hex editor shows that this isn't UTF8 and again file-command agrees. If I insert any data into the database with DBI, it will be entered as double-UTF8'd. The system has PostgreSQL 10, Perl 5.26.1, DBI 1.640 and DBD::pg 3.7.0. So dear monks, what's going on?
Back to
Seekers of Perl Wisdom
|
|