On Mon, April 10, 2006 04:01, Roman Shchugarev wrote:

> Thanks for a tip BART I've managed to get out a Unicode data using
> these
> simple functions (WideCharToMultiByte/MultiByteToWideChar):
> string toNarrowString( const wchar_t* pStr , int len )
, and may depend on your locale.> {
>      ASSERT( len >= 0 || len == -1 , _T("Invalid string length: ") =
> 0 || len == -1 , _T("Invalid string length: ")

Be careful though: the reason why libpqxx can't simply convert your string
for you is that it doesn't know what encoding the string is in!

The database itself is configured to keep its data in a particular
encoding, which in the modern world will *typically* be UTF-8.  But this
isn't always the case.  Also, even if the data is kept as unicode it
doesn't really matter whether it's in UTF-8 or some other encoding, since
the data will then be converted to your client encoding, and sent to you
in that form.

By default, your client encoding will be whatever your client program's
locale setting is.  But you can also explicitly specify to the backend
what encoding you want your data in using the connection's
set_client_encoding() function.  I want to support these conversions at
some point, but just haven't had much time to look into it!


Jeroen


_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general

Reply via email to