From: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> |
---|---|
To: | V S P <toreason(at)fastmail(dot)fm> |
Cc: | pgsql-odbc(at)postgresql(dot)org |
Subject: | Re: [Q] UTF-8 testing with Windows/ODBC 8.3.0400 |
Date: | 2009-03-18 06:46:54 |
Message-ID: | 49C098DE.1010807@postnewspapers.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-odbc |
V S P wrote:
> My C++ program relies on OTL C++ library to do DB access, and in the
> Visual Studio debugger I see only question marks '?' for the strings.
How would Visual Studio know that the std::string instances in question
contain UTF-8 data? std::string is a byte string, not a character string
- it could contain text in any encoding (or non-text data) and VC++ has
no way of knowing how to interpret it.
What it probably does is display anything within the ASCII range, and
otherwise display ?s .
If you expect to be able to work with those strings as real text, you
probably want to use std::wstring instead, and USE APPROPRIATE ENCODING
CONVERSION ROUTINES. Note that the width of wchar_t varies from platform
to platform, so you'll need to convert to/from UTF-16 for a 2 byte
wchar_t, or to/from UTF-32 for a 4-byte wchar_t.
(I hate working with unicode and encodings in standard C++ *SO* much -
argh! One of the only areas where I really wish I was using Java. If
only the QString class from Qt was part of standard C++ ... ).
> I am using std::string to store the bytestream from varchar column an I
> think it is ok
> because I do not need to 'manipulate' the content.
True - but VC++ won't be able to understand what's in it, either.
> I cannot figure out what else I might be doing wrong.... as I said, all
> I need for now it is just to test out that a C++ program via ODBC can
> get the data.
Your description really isn't adequate to say. It's highly likely that
you're retrieving the data from the database fine, but your tools don't
know it's UTF-8 and aren't able to work with it correctly. That's mostly
a guess with the amount of information you've provided, though.
Perhaps you could post a small, self-contained test program and a SQL
script to populate a test database? Then post the results of running the
program against the database, including the hex values of the bytes
returned by the ODBC interface.
--
Craig Ringer
From | Date | Subject | |
---|---|---|---|
Next Message | V S P | 2009-03-18 08:09:49 | Re: [Q] UTF-8 testing with Windows/ODBC 8.3.0400 |
Previous Message | V S P | 2009-03-17 19:16:22 | [Q] UTF-8 testing with Windows/ODBC 8.3.0400 |