> -----Original Message-----
> From: Brodie Thiesfield [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 20, 2006 12:17 PM
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] Need a wince test
> 
> Robert, does the patch I provided work as is on Windows CE or not?
> 
> Robert Simpson wrote:
> > There's some flaws in your arguments, Brodie ...
> >
> > 1.  There's no need to do this whole _UNICODE test, only the _WINCE
> test is
> > needed.  All versions of Windows that support unicode also support
> the ANSI
> > versions of the API calls -- the only Windows platform that doesn't
> have any
> > ANSI support is Windows CE.  A single one-character modification to
> DRH's
> > proposed patch is all that's needed for regular Windows desktop
> support.
> 
> Robert, you are missing the point. Because of the way this is being
> defined, there is a need to check for _UNICODE. If you don't then a
> build with _UNICODE defined will fail. If it was implemented like the
> rest of the functions in os_win.c then it wouldn't be necessary.

I can go either way on that.  There is no need to check for _UNICODE if you
change the defines from this:

# ifdef _WIN32_WCE
//snip
# else
#   define SQLITE_OPEN_LIBRARY(A)  LoadLibrary(A)
#   define SQLITE_FIND_SYMBOL(A,B) GetProcAddress(A,B)
# endif

To this:

# ifdef _WIN32_WCE
//snip
# else
#   define SQLITE_OPEN_LIBRARY(A)  LoadLibraryA(A) // <-- changed to A
#   define SQLITE_FIND_SYMBOL(A,B) GetProcAddress(A,B)
# endif

Here's what I propose ...

#ifdef _UNICODE
#define OSSTR wchar_t
#else
#define OSSTR char

OSSTR *utf8toOS(char *utf8)
{
  // for windows, allocate and return an OS string of the right encoding and
type
  // For *nix, return the utf8 string as-is
}
void utf8toOSFree(OSSTR *apiString)
{
  // For windows, free the apiString
  // For *nix, do nothing
}

Once those are declared in all the os's, then we can dispense with the
rigamarol of calling CreateFileW and CreateFileA, and LoadLibraryW and
LoadLibraryA, etc.  Anytime you make an OS-level call, you call these two
functions to allocate and free an appropriately-converted string.  On *nix
these will be noop functions.

There will still be one exception, but its minor.  GetProcAddress() in
Windows takes an ANSI string for the function name always.  However, since
you can't export a function with a name outside the normal ASCII range,
there's no need to convert the utf8 string to an OS-specific string.
 
Robert




-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to