[Libpqxx-general] libqxx with unicode client encoding
Peter Geoghegan
peter.geoghegan86 at gmail.com
Tue Jun 17 14:56:41 UTC 2008
Taras,
> Can someone please tell me if library is working fine with client
> encoding set to UTF-8?
Provided the strings that you give libpqxx are valid UTF-8 byte
sequences, they should be stored correctly. If they are not, and
client encoding is set to UTF-8, libpqqxx will throw an exception. Try
storing non-ascii characters(Japanese or something) using your
application, and then retrieving them. Be aware that postgreSQL lacks
any intrinsic understanding of what human readable text these bytes
are - it doesn't know what unicode codepoints they resolve to - it
just knows that they are, or are not, valid for the particular
encoding in question, and enforces that. If you use the SQL-ascii
client encoding, Postgres happily stores whatever bytes you throw at
it, including non-printable ascii control characters, or characters in
the range /128 - /255 or whatever. If you attempt to store strings of
some ascii-superset other then UTF-8 with a UTF-8 database, postgreSQL
won't complain until you attempt to store non-ascii characters. Hope
that helps,
Regards,
Peter
More information about the Libpqxx-general
mailing list