diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-02-07 08:02:52 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-02-07 08:02:52 +0200 |
commit | 7aa23d94dd5dd487aa9752aec5944d2d225cafa0 (patch) | |
tree | ab5be9cea663de6bb34c82150add457451bb176b | |
parent | 91909053d95f2373dbd2ddb4281bbaa0103dbe44 (diff) |
Use fromUtf8() instead of fromStdString() for NCHAR initialization
-rw-r--r-- | qt/oracle/basic/driver.cxx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/qt/oracle/basic/driver.cxx b/qt/oracle/basic/driver.cxx index 9b852d8..f50c45e 100644 --- a/qt/oracle/basic/driver.cxx +++ b/qt/oracle/basic/driver.cxx @@ -35,7 +35,9 @@ main (int argc, char* argv[]) string short_str (13, 's'); string medium_str (150, 'm'); string long_str (20000, 'v'); - string unicode_str ("a \xD5\x95 \xEA\xAA\xAA \xF2\xAA\xAA\xAA"); + // Oracle UTF-8 support is limited to 3-byte sequences. + // + string unicode_str ("a \xD5\x95 \xEA\xAA\xAA \xE2\x82\xAC bcdef"); object o; @@ -43,8 +45,10 @@ main (int argc, char* argv[]) o.varchar2 = QString::fromStdString (medium_str); o.clob = QString::fromStdString (long_str); - o.nchar= QString::fromStdString (unicode_str); - o.nvarchar2 = QString::fromStdString (unicode_str); + // fromStdString() assumes ASCII in Qt4 and UTF-8 in Qt5. + // + o.nchar= QString::fromUtf8 (unicode_str.c_str (), unicode_str.size ()); + o.nvarchar2 = QString::fromUtf8 (unicode_str.c_str (), unicode_str.size ()); o.nclob = QString::fromStdString (long_str); o.raw = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8); @@ -63,10 +67,9 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); - object* ol = db->load<object> (o.varchar2); + std::auto_ptr<object> p (db->load<object> (o.varchar2)); t.commit (); - - assert (*ol == o); + assert (*p == o); } } catch (const odb::exception& e) |