Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to open a file with UNICODE filename on Windows?

How to open a file with UNICODE filename on Windows?

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zengkun100
    wrote on last edited by
    #1

    There is a 3rd lib only accept char* filename e.g.

    3rdlib_func_name(char* file_name)

    . Every things get wrong when I provide a filename in Chinese or Japanese. Is there any way to make this lib open UNICODE filename? The program is running on Windows. Thanks for your reply.

    A Chinese VC++ programmer

    L F 2 Replies Last reply
    0
    • Z zengkun100

      There is a 3rd lib only accept char* filename e.g.

      3rdlib_func_name(char* file_name)

      . Every things get wrong when I provide a filename in Chinese or Japanese. Is there any way to make this lib open UNICODE filename? The program is running on Windows. Thanks for your reply.

      A Chinese VC++ programmer

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      zengkun100 wrote:

      Is there any way to make this lib open UNICODE filename?

      Only by changing its source code. You will have to go to the suppliers of the library to get it changed if you do not have the source.

      It's time for a new signature.

      Z 1 Reply Last reply
      0
      • Z zengkun100

        There is a 3rd lib only accept char* filename e.g.

        3rdlib_func_name(char* file_name)

        . Every things get wrong when I provide a filename in Chinese or Japanese. Is there any way to make this lib open UNICODE filename? The program is running on Windows. Thanks for your reply.

        A Chinese VC++ programmer

        F Offline
        F Offline
        Fareed Rizkalla
        wrote on last edited by
        #3

        If your app is UNICODE! Their is a function to change UNICODE string to CHAR! wcstombs[^] But I guess that won't fix it either if your filenames are in UNICODE.

        Z 1 Reply Last reply
        0
        • F Fareed Rizkalla

          If your app is UNICODE! Their is a function to change UNICODE string to CHAR! wcstombs[^] But I guess that won't fix it either if your filenames are in UNICODE.

          Z Offline
          Z Offline
          zengkun100
          wrote on last edited by
          #4

          Fareed Rizkalla wrote:

          If your app is UNICODE! Their is a function to change UNICODE string to CHAR! wcstombs[^] But I guess that won't fix it either if your filenames are in UNICODE.

          Yes, even if I transferred the UNICODE filename to a char*(using CP_ACP or CP_UTF8), the 3rd lib don't accept this filename and returns a "file not found" error code.

          A Chinese VC++ programmer

          1 Reply Last reply
          0
          • L Lost User

            zengkun100 wrote:

            Is there any way to make this lib open UNICODE filename?

            Only by changing its source code. You will have to go to the suppliers of the library to get it changed if you do not have the source.

            It's time for a new signature.

            Z Offline
            Z Offline
            zengkun100
            wrote on last edited by
            #5

            Richard MacCutchan wrote:

            Only by changing its source code. You will have to go to the suppliers of the library to get it changed if you do not have the source.

            I think so. In theory, char* cant only be used to point to a UTF8 UNICODE string, however, you cannot give a UTF8 filename to fopen or some other file functions. But if I transfer this UNICODE filename to char* using CP_ACP, some of the characters cannot be changed.

            A Chinese VC++ programmer

            L 1 Reply Last reply
            0
            • Z zengkun100

              Richard MacCutchan wrote:

              Only by changing its source code. You will have to go to the suppliers of the library to get it changed if you do not have the source.

              I think so. In theory, char* cant only be used to point to a UTF8 UNICODE string, however, you cannot give a UTF8 filename to fopen or some other file functions. But if I transfer this UNICODE filename to char* using CP_ACP, some of the characters cannot be changed.

              A Chinese VC++ programmer

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Exactly right, which is why all software suppliers should be providing full Unicode support. I think you need to talk to the supplier of the library and get them to change it. You may also note that _wfopen is the Unicode version of the file open function, so there is no problem with Unicode file names.

              It's time for a new signature.

              Z 1 Reply Last reply
              0
              • L Lost User

                Exactly right, which is why all software suppliers should be providing full Unicode support. I think you need to talk to the supplier of the library and get them to change it. You may also note that _wfopen is the Unicode version of the file open function, so there is no problem with Unicode file names.

                It's time for a new signature.

                Z Offline
                Z Offline
                zengkun100
                wrote on last edited by
                #7

                Thanks for your reply again :) We have called our partner this afternoon.

                A Chinese VC++ programmer

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups