Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
As the author of DBIx::Log4perl I can guarantee you that DBIx::Log4perl gets any SQL passed to do/prepare before DBI and before DBD::Pg.

In this case I wonder why DBIx logs UTF-8 bytes, whereas Log4perl "outside" of DBI/DBIx does not. There must be some interference there, anything is getting passed a UTF-8 Perlstring and encodes it to UTF-8 bytes.

It seems like you are suggesting that when your client chrset is 1252 and you pass UTF8 to DBD::Pg then the data isn't right in the database?

It's wrong if the target database is WIN1252 as well, it works if the target is UTF-8. This is simply because in each case UTF-8 bytes gets transferred and they are 1:1 stored in the target, which results in UTF-8 bytes in a WIN1252 target and properly UTF-8 characters in a UTF-8 target.

I wouldn't expect it to be since postgres thinks it is 1252 but you sent utf8.

I don't send UTF-8, I give a valid UTF-8 Perlstring and DBD::Pg should handle the communication on it's own. But it doesn't, it always sends UTF-8 bytes regardless of the client encoding, but the client encoding is recognized by the server to reinterpret what it gets. If client encoding is UTF-8 it matches the data sent and the server can encode properly into WIN1252 for WIN1252 target database, but if both differ I get garbage in the target and that's what I don't understand: Why does DBD::Pg always sends UTF-8 bytes and not WIN1252 if the client encoding says so?

Regarding the docs there should be automatic conversion depending on the client encoding. But it doesn't work this way.

If you have UTF8 encoded data then set your client chrset to utf8.

But especially with having UTF-8 strings on the client DBD::Pg should be able to convert into any charset it likes. I don't understand why I'm forced to set the client encoding to some internal representation DBD::Pg sends over the wire and why this doesn't seem to be documented. The documentation says otherwise, that conversion takes place automatically between client and server and I understand that for sending data as well.

If you want utf8 back then set pg_enable_utf8 - I didn't see a deprecated warning anywhere and I can assure you it is used all over the DBD::Pg code.

Regarding this source it gets deprecated in the future, but my problem is not with reading data anyways.


In reply to Re^6: DBD::Pg encodes Perlstring to UTF-8 bytes instead of WIN1252 regardless client encoding by Pickwick
in thread DBD::Pg encodes Perlstring to UTF-8 bytes instead of WIN1252 regardless client encoding by Pickwick

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-03-19 10:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found