Hello sqlite-users,

  I'm on a US English version of windows XP, latest patches. From time
to time my users report that they can't open a database that's
clearly sitting there in the file system.

I've tracked the problem down to high ascii in the path.

For instance

D:\DataBoy\GROUPS.DB3

works

D:\DataƩBoy\GROUPS.DB3

Doesn't. It's consistent on my machine and the machines of my users.


I changed os_win.c to match my own ascii to unicode functions and now
it works.

#ifdef ORIGINAL
static WCHAR *utf8ToUnicode(const char *zFilename){
  int nByte;
  WCHAR *zWideFilename;

  if( !isNT() ){
    return 0;
  }
  nByte = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0)*sizeof(WCHAR);
  zWideFilename = sqliteMalloc( nByte*sizeof(zWideFilename[0]) );
  if( zWideFilename==0 ){
    return 0;
  }
  nByte = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, nByte);
  if( nByte==0 ){
    sqliteFree(zWideFilename);
    zWideFilename = 0;
  }
  return zWideFilename;
}
#endif
static WCHAR *utf8ToUnicode(const char *zFilename){
  int nByte;
  WCHAR *zWideFilename;

  if( !isNT() ){
    return 0;
  }
  nByte = MultiByteToWideChar
 (
        CP_ACP,
        MB_PRECOMPOSED,
        zFilename, 
        -1, 
        NULL, 
        0
  )*sizeof(WCHAR);
  zWideFilename = sqliteMalloc( nByte*sizeof(zWideFilename[0]) );
  if( zWideFilename==0 ){
    return 0;
  }
        nByte = MultiByteToWideChar
        (
                CP_ACP,
                MB_PRECOMPOSED,
                zFilename, 
                -1, 
                zWideFilename, 
                nByte
        );
        if( nByte==0 )
        {
    sqliteFree(zWideFilename);
    zWideFilename = 0;
  }
  return zWideFilename;
}


static char *unicodeToUtf8(const WCHAR *zWideFilename){
  int nByte;
  char *zFilename;

#ifdef ORIGINAL
  nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, 0, 0, 0, 0);
  zFilename = sqliteMalloc( nByte );
  if( zFilename==0 ){
    return 0;
  }
  nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, zFilename, nByte,
                              0, 0);
#endif
  nByte = WideCharToMultiByte(CP_ACP, 0, zWideFilename, -1, 0, 0, 0, 0);
  zFilename = sqliteMalloc( nByte );
  if( zFilename==0 ){
    return 0;
  }
  nByte = WideCharToMultiByte(CP_ACP, 0, zWideFilename, -1, zFilename, nByte,
                              0, 0);

  if( nByte == 0 ){
    sqliteFree(zFilename);
    zFilename = 0;
  }
  return zFilename;
}


The difference is the flags I'm passing. Using the UTF8 flag of the
original code, the high ascii character isn't translated and is
dropped from the string so, the open call always fails.

You may have already fixed this, I don't track the versions as closely
as I should.


-- 
Best regards,
 Conrad                          mailto:[EMAIL PROTECTED]


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

Reply via email to