UTF-8 Encoding and Decoding (RT #40199)
"David E. Wheeler" <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.dbdpg |
|---|---|
| Message-ID | <[email protected]> |
Fellow DBD::Pgers, I'm wondering where we stand on [RT #40199](https://rt.cpan.org/Ticket/Display.html?id=40199 ). If I read that thread correctly, it seems that the way DBD::Pg handles pg_enable_utf8 could be improved. To quote RhodiumToad: > Since you're not requesting binary-format results, then what you get > back from the server is in text format. > > If the result is in text format, AND the value of client_encoding is > 'UTF8', then the content is expected to be UTF8, REGARDLESS OF TYPE > (yes, even for bytea, since it's escaped when you get it from the > server). So the utf8 flag should be set in ALL such cases except when > you've applied type-specific transformations to the result (such as in > dequote_bytea). > > The code should absolutely not make assumptions about types. Assuming that DBD::Pg does, in fact, get back results in text format, it seems safe to assume that the text will always be in the format specified in client_encoding. If that's UTF-8, we could just set the utf8 flag on everything (except for bytea data). If we wanted to maximize backwards compatibility, we could do this only when pg_enable_utf8 is set to a true value, but it seems to me that it's not really necessary. So what would it take to make this change? Thanks, David