September 09, 2004
contains the lines:

  clength = std.string.strlen(fileinfo.cFileName);
  wbuf.length = MultiByteToWideChar(0,0,fileinfo.cFileName,clength,null,0);
  n = MultiByteToWideChar(0,0,fileinfo.cFileName,clength,cast(wchar*)wbuf,wbuf.length);
  assert(n == wbuf.length);
  if (!callback(std.utf.toUTF8(wbuf)))
    . . .

It's possible, albiet unlikely, that the filename is changed (to be shorter) between the two WC2MB calls, and therefore
the assert() is inappropriate.

Should be:

  clength = std.string.strlen(fileinfo.cFileName);
  wbuf.length = MultiByteToWideChar(0,0,fileinfo.cFileName,clength,null,0);
  n = MultiByteToWideChar(0,0,fileinfo.cFileName,clength,cast(wchar*)wbuf,wbuf.length);
  assert(n <= wbuf.length);
  if(n < wbuf.length)
  {
    wbuf = wbuf[0 .. n];
  }
  if (!callback(std.utf.toUTF8(wbuf)))
    . . .



September 09, 2004
Forget everything I just said.

"Matthew" <admin@stlsoft.dot.dot.dot.dot.org> wrote in message news:chorsg$1oi8$1@digitaldaemon.com...
> contains the lines:
>
>   clength = std.string.strlen(fileinfo.cFileName);
>   wbuf.length = MultiByteToWideChar(0,0,fileinfo.cFileName,clength,null,0);
>   n = MultiByteToWideChar(0,0,fileinfo.cFileName,clength,cast(wchar*)wbuf,wbuf.length);
>   assert(n == wbuf.length);
>   if (!callback(std.utf.toUTF8(wbuf)))
>     . . .
>
> It's possible, albiet unlikely, that the filename is changed (to be shorter) between the two WC2MB calls, and
therefore
> the assert() is inappropriate.
>
> Should be:
>
>   clength = std.string.strlen(fileinfo.cFileName);
>   wbuf.length = MultiByteToWideChar(0,0,fileinfo.cFileName,clength,null,0);
>   n = MultiByteToWideChar(0,0,fileinfo.cFileName,clength,cast(wchar*)wbuf,wbuf.length);
>   assert(n <= wbuf.length);
>   if(n < wbuf.length)
>   {
>     wbuf = wbuf[0 .. n];
>   }
>   if (!callback(std.utf.toUTF8(wbuf)))
>     . . .
>
>
>