ISAPI unicode filenames
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: ISAPI unicode filenames

Hybrid View

  1. #1
    Join Date
    Aug 2009
    Posts
    3

    Unhappy ISAPI unicode filenames

    Hi good people! I have a unicode problem; I have created a ISAPI DLL in C++ that takes in a filename and then sends a file to the requesting client. (The DLL is executed from a browser.)

    Problem is that when I send in a Japanese filename (where each character need two bytes) the application believes the file doesn't exist.

    I'm trying to get a file named "日本語.jpg".
    This is turned into ANSI characters in the application: "日本語.jpg".

    Then when I try to open the file:

    Code:
    HANDLE fileHandle = CreateFile(
      filePath,  //the file path, char *filePath
      GENERIC_READ,
      FILE_SHARE_READ,
      NULL,
      OPEN_EXISTING,
      FILE_ATTRIBUTE_NORMAL,
      NULL
    );
    ...it doesn't find the file since it checks for the ANSI version of the Unicode file name. If I rename the file to "日本語.jpg" and then try to get "日本語.jpg" I can get the file (but that means I have to rename the files to weird symbols).

    The question is:

    Can I make it so that the CreateFile function understands that "filePath" is Unicode and not ANSI? Or is there some other way to get a HANDLE to the correct file?

    Desperate for help, I just discovered this and if there is no way of fixing it it will mean I have wasted weeks coding for a broken system!

  2. #2
    Join Date
    Nov 2001
    Posts
    251

    Re: ISAPI unicode filenames

    CreateFile is just a macro for CreateFileA and CreateFileW.
    Use CreateFileW for Unicode filenames, or just compile your entire project as Unicode.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center