From cb23b26f09cdc4f2da380dac7bd43327839526de Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Wed, 23 Mar 2011 18:15:28 +0200 Subject: Persist and load QString as UTF8 string --- odb/qt/mysql/qstring-traits.hxx | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/odb/qt/mysql/qstring-traits.hxx b/odb/qt/mysql/qstring-traits.hxx index 5b0191a..d179972 100644 --- a/odb/qt/mysql/qstring-traits.hxx +++ b/odb/qt/mysql/qstring-traits.hxx @@ -10,16 +10,17 @@ #include // std::size_t -#include -#include - #include +#include +#include +#include + namespace odb { namespace mysql { - class LIBODB_MYSQL_EXPORT qstring_value_traits + class LIBODB_QT_EXPORT qstring_value_traits { public: typedef QString value_type; @@ -33,7 +34,7 @@ namespace odb bool is_null) { if (!is_null) - v = QString::fromLocal8Bit (b.data (), n); + v = QString::fromUtf8 (b.data (), n); else v.clear (); } @@ -46,37 +47,37 @@ namespace odb { is_null = false; - const std::string& s (v.toStdString ()); - n = s.size (); + const QByteArray& a (v.toUtf8 ()); + n = a.size (); if (n > b.capacity ()) b.capacity (n); if (n != 0) - memcpy (b.data (), s.data (), n); + memcpy (b.data (), a.data (), n); } }; template <> - struct LIBODB_MYSQL_EXPORT default_value_traits< + struct LIBODB_QT_EXPORT default_value_traits< QString, details::buffer, id_string>: qstring_value_traits { }; template <> - struct LIBODB_MYSQL_EXPORT default_value_traits< + struct LIBODB_QT_EXPORT default_value_traits< QString, details::buffer, id_decimal>: qstring_value_traits { }; template <> - struct LIBODB_MYSQL_EXPORT default_value_traits< + struct LIBODB_QT_EXPORT default_value_traits< QString, details::buffer, id_enum>: qstring_value_traits { }; template <> - struct LIBODB_MYSQL_EXPORT default_value_traits< + struct LIBODB_QT_EXPORT default_value_traits< QString, details::buffer, id_set>: qstring_value_traits { }; -- cgit v1.1