[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: LMDB and text encoding



My take:

On 27. jan. 2015 22:39, Timur Kristóf wrote:
> 1. Database names

MDB_val here sounds nice...

2. Path names

Functions like mdb_env_open, mdb_env_get_path, mdb_env_copy and the
likes accept a char* for path names. This is fine on most unixes where
char* is an UTF-8 string, but unfortunately, these functions call the
ANSI variants of the Windows API functions, making it impossible to
use Unicode path names with them.

I think we should switch to the widechar APIs instead, but that would
also mean changing the LMDB API to accept a wchar_t* parameter on
Windows instead of char*.

My initial reaction is that an API with different prototypes for
Windows and Unix sounds bad.  Unix must have char* since it does
not even support wchar_t* filenames, and it should be simple to
write a portable OS-unaware LDMB program.

Though I notice Windows #defines CreateFile() & co as CreateFileA
or CreateFileW depending on whether or not UNICODE is #defined (and
some other macros), without even mentioning this in the CreateFile()
doc.  I suppose ldmb.h could do something similar - but with doc:-)

What's the norm for Windows libraries?  Google found TCHAR stuff
which becomes WCHAR or char depending on defined(UNICODE), and
apparently strong religions about whether if it's a good or bad
idea for portable libraries to do the same.  #define MDB_TEXT(str)
as str or L##str depending on UNICODE, etc.

--
Hallvard