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. MultiByteToWideChar fails in Vista (french) OS

MultiByteToWideChar fails in Vista (french) OS

Scheduled Pinned Locked Moved C / C++ / MFC
jsonquestion
9 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.
  • S Offline
    S Offline
    Sunil P V
    wrote on last edited by
    #1

    Hi All, I am using the API 'MultiByteToWideChar' for converting the ASCII char buffer to unicode. This fails indefinitely on Windows Vista french OS. The API returns the number of characters converted. Below is the actual text: 'Carte réseau' After calling the API, the text returned is something like this: Carte r?seau Please provide your inputs on this. Thanks for your time. Regards

    Sunil

    S S J 3 Replies Last reply
    0
    • S Sunil P V

      Hi All, I am using the API 'MultiByteToWideChar' for converting the ASCII char buffer to unicode. This fails indefinitely on Windows Vista french OS. The API returns the number of characters converted. Below is the actual text: 'Carte réseau' After calling the API, the text returned is something like this: Carte r?seau Please provide your inputs on this. Thanks for your time. Regards

      Sunil

      S Offline
      S Offline
      Sunil P V
      wrote on last edited by
      #2

      BTW, forgot to mention, below are the parameters to the API: char Description[132] = {0}; char Description[132] = {0}; TCHAR szName[132] = {0}; . . . . int nLen = MultiByteToWideChar(CP_UTF8, 0, Description, -1, szName, SIZEOF_ARRAY(szName)); // nLen is around 30, the no. of chars copied

      Sunil

      1 Reply Last reply
      0
      • S Sunil P V

        Hi All, I am using the API 'MultiByteToWideChar' for converting the ASCII char buffer to unicode. This fails indefinitely on Windows Vista french OS. The API returns the number of characters converted. Below is the actual text: 'Carte réseau' After calling the API, the text returned is something like this: Carte r?seau Please provide your inputs on this. Thanks for your time. Regards

        Sunil

        S Offline
        S Offline
        sujeet
        wrote on last edited by
        #3

        This API works fine. The problem is your machine language may be set to English. So first set the machine language to French. Go to Control Panel->Regional and Language options In both "Regional Options" and "Advanced" tabs selct Frech language. It will ask you to reboot the machine. Reboot it and check now. It will work fine. Cheers, Sujeet Pandurang Kumbhar.

        modified on Monday, May 25, 2009 2:20 AM

        J S 2 Replies Last reply
        0
        • S Sunil P V

          Hi All, I am using the API 'MultiByteToWideChar' for converting the ASCII char buffer to unicode. This fails indefinitely on Windows Vista french OS. The API returns the number of characters converted. Below is the actual text: 'Carte réseau' After calling the API, the text returned is something like this: Carte r?seau Please provide your inputs on this. Thanks for your time. Regards

          Sunil

          J Offline
          J Offline
          Joe Woodbury
          wrote on last edited by
          #4

          The accented e is a second, third, or fourth byte of a multi-byte sequence for a UTF-8 encoding and thus is invalid as a stand-alone character. You should likely use 1252 as the code page.

          Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

          S 1 Reply Last reply
          0
          • S sujeet

            This API works fine. The problem is your machine language may be set to English. So first set the machine language to French. Go to Control Panel->Regional and Language options In both "Regional Options" and "Advanced" tabs selct Frech language. It will ask you to reboot the machine. Reboot it and check now. It will work fine. Cheers, Sujeet Pandurang Kumbhar.

            modified on Monday, May 25, 2009 2:20 AM

            J Offline
            J Offline
            Joe Woodbury
            wrote on last edited by
            #5

            "é" is an ANSI character (code page 1252), but doesn't have a single character representation in UTF-8. Please remove your answer because it is 100% wrong.

            Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

            1 Reply Last reply
            0
            • S sujeet

              This API works fine. The problem is your machine language may be set to English. So first set the machine language to French. Go to Control Panel->Regional and Language options In both "Regional Options" and "Advanced" tabs selct Frech language. It will ask you to reboot the machine. Reboot it and check now. It will work fine. Cheers, Sujeet Pandurang Kumbhar.

              modified on Monday, May 25, 2009 2:20 AM

              S Offline
              S Offline
              Sunil P V
              wrote on last edited by
              #6

              Thanks Sujeet. But as you said my system language is already set to French. Not sure why the problem still exists. Could you think of anything else ? Thanks

              Sunil

              1 Reply Last reply
              0
              • J Joe Woodbury

                The accented e is a second, third, or fourth byte of a multi-byte sequence for a UTF-8 encoding and thus is invalid as a stand-alone character. You should likely use 1252 as the code page.

                Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                S Offline
                S Offline
                Sunil P V
                wrote on last edited by
                #7

                Hello Thanks for your time. It is not only this character that is failing, but it definitely fails on Chinese/Japanese as well. Could you think of anything else ? Also i use a lenevo c200 system, one which i have encountered numerous string errors in my dev life :^) . Thanks

                Sunil

                J 1 Reply Last reply
                0
                • S Sunil P V

                  Hello Thanks for your time. It is not only this character that is failing, but it definitely fails on Chinese/Japanese as well. Could you think of anything else ? Also i use a lenevo c200 system, one which i have encountered numerous string errors in my dev life :^) . Thanks

                  Sunil

                  J Offline
                  J Offline
                  Joe Woodbury
                  wrote on last edited by
                  #8

                  You have to correctly identify the code page of the original string. You are not. If you have a multi-byte Japanese string using Shift-JIS, you need to use that, not UTF-8. The point is that UTF-8 is a very specific encoding, not just multi-byte in general.

                  Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                  S 1 Reply Last reply
                  0
                  • J Joe Woodbury

                    You have to correctly identify the code page of the original string. You are not. If you have a multi-byte Japanese string using Shift-JIS, you need to use that, not UTF-8. The point is that UTF-8 is a very specific encoding, not just multi-byte in general.

                    Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                    S Offline
                    S Offline
                    Sunil P V
                    wrote on last edited by
                    #9

                    You are right. We need to identify the appropriate code page and then accordingly use UTF8/ACP. I think for eastern languages it is UTF8 and for European languages it is ACP. Thanks a lot for your help.

                    Sunil

                    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