SQLiteCpp icon indicating copy to clipboard operation
SQLiteCpp copied to clipboard

Add support for C++ Unicode types

Open dougnazar opened this issue 3 years ago • 4 comments

Add support for using char8_t, char16_t, wchar_t, u8string, u16string & wstring when available. wchar_t & wstring support are only available on platforms with a 2 byte wchar_t.

Usable to create Statements, bind parameters and retrieve column data.

The first commit is a fix for when the native database is in UTF-16 format and you try to extract a std::string.

dougnazar avatar Dec 06 '22 01:12 dougnazar

Hey hello @dougnazar, I have merged only the first of your commits, the bugfix & unit tests, in order to release a 3.2.1 bugfix release ASAP without changes to APIs Thanks

SRombauts avatar Dec 11 '22 21:12 SRombauts

@dougnazar what about char32_t and u32string? I'm using it al lot in asian language tools. Are you planning to create new PR with it or I'll do it instead when all your commits will be merged. @SRombauts when are you planning to merge at least bind-related commits? I believe it's very useful feature.

Pugnator avatar Jan 08 '23 13:01 Pugnator

Unfortunately SQLite doesn't natively support UTF-32, so there is no API to pass through to. They've recently added sqlite3_bind_text64() however it only accepts SQLITE_UTF8, SQLITE_UTF16, SQLITE_UTF16BE, or SQLITE_UTF16LE.

I'm not sure that SQLiteC++ is the correct layer to handle the conversion. It would add a hidden performance cost for using that API.

dougnazar avatar Jan 08 '23 14:01 dougnazar

Unfortunately SQLite doesn't natively support UTF-32, so there is no API to pass through to. They've recently added sqlite3_bind_text64() however it only accepts SQLITE_UTF8, SQLITE_UTF16, SQLITE_UTF16BE, or SQLITE_UTF16LE.

I'm not sure that SQLiteC++ is the correct layer to handle the conversion. It would add a hidden performance cost for using that API.

I agree, will stick to external 32-16 conversion until it's natively supported. Thank you for your enhancements!

Pugnator avatar Jan 08 '23 14:01 Pugnator