[odb-users] std::wstring support for sqlite on Linux
boris at codesynthesis.com
Fri Jan 30 09:10:42 EST 2015
dieter.govaerts at bricsys.com <dieter.govaerts at bricsys.com> writes:
> In the release notes for ODB 2.1.0 I see that std::wstring support
> has been added for SQLite databases but only on Windows. When will
> this become available for Linux (and Mac)?
On Windows, wchar_t (the character type for wstring) is 2 bytes and
is assumed to store UTF-16 code points. SQLite API also accepts
On UNIX (Linux, Mac OS, etc), however, the size of wchar_t varies and
there is no common convention for what it actually stores. On both
Linux and Mac OS, wchar_t is 4 bytes and the most natural thing to
assume is that it stores UTF-32. SQLite API does not work with UTF-32
text directly so that means (provided we make this assumption), ODB
will have to convert things back and forth. For these two reasons
there are no plans to support wstring in ODB for UNIX platforms.
> We are developing a cross-platform, unicode enabled application.
> Without this feature on Linux I will have to convert all unicode
> strings to UTF8 and back somewhere along the way which would
> complicate the now easy getters & setters.
Hm, for a cross-platform application, UTF-8 would actually be the
more natural choice.
If you want to use UTF-16 everywhere, then the better approach
would be to use std::u16string from C++11 which is specified to
store UTF-16 strings. We can add support for this mapping to ODB.
More information about the odb-users