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. Unicode Conversion

Unicode Conversion

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
8 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.
  • V Offline
    V Offline
    Vineet Kumar
    wrote on last edited by
    #1

    Hi, I am working on Unicode conversion and getting a problem to convert a character in to UTF-8 format. can anybody suggest that how to do this conversion. Regs Vineet

    Vineet Kumar Singhal Sr.Software Engineer Mumbai Tough Time Never last, but Tough People do.

    T M 2 Replies Last reply
    0
    • V Vineet Kumar

      Hi, I am working on Unicode conversion and getting a problem to convert a character in to UTF-8 format. can anybody suggest that how to do this conversion. Regs Vineet

      Vineet Kumar Singhal Sr.Software Engineer Mumbai Tough Time Never last, but Tough People do.

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      SKVineet wrote:

      I am working on Unicode conversion and getting a problem to convert a character in to UTF-8 format.

      look at MultiByteToWideChar

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

      M 1 Reply Last reply
      0
      • V Vineet Kumar

        Hi, I am working on Unicode conversion and getting a problem to convert a character in to UTF-8 format. can anybody suggest that how to do this conversion. Regs Vineet

        Vineet Kumar Singhal Sr.Software Engineer Mumbai Tough Time Never last, but Tough People do.

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        You'll need the text in UTF-16 first, then call WideCharToMultiByte() passing the CP_UTF8 value for the code page.

        --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

        V 1 Reply Last reply
        0
        • T ThatsAlok

          SKVineet wrote:

          I am working on Unicode conversion and getting a problem to convert a character in to UTF-8 format.

          look at MultiByteToWideChar

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

          cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          MultiByteToWideChar() is for converting to UTF-16 only.

          --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

          T 1 Reply Last reply
          0
          • M Michael Dunn

            MultiByteToWideChar() is for converting to UTF-16 only.

            --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            Michael Dunn wrote:

            is for converting to UTF-16 only.

            just a ?.... codepage argument take UTF -8 ?.. is MSDN documentation wrong?

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

            M 1 Reply Last reply
            0
            • T ThatsAlok

              Michael Dunn wrote:

              is for converting to UTF-16 only.

              just a ?.... codepage argument take UTF -8 ?.. is MSDN documentation wrong?

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

              M Offline
              M Offline
              Michael Dunn
              wrote on last edited by
              #6

              The codepage argument to MultiByteToWideChar() says what the encoding of the MBCS string is. MultiByteToWideChar() converts from that encoding to UTF-16.

              --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

              1 Reply Last reply
              0
              • M Michael Dunn

                You'll need the text in UTF-16 first, then call WideCharToMultiByte() passing the CP_UTF8 value for the code page.

                --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

                V Offline
                V Offline
                Vineet Kumar
                wrote on last edited by
                #7

                Hi, I tried with that , but could not found the desired result. In fact the stepa which I followed are as: 1. First I got the characters in the rtf string for a character(say chinese) I typed. ex:\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\fmodern\\fprq6\\fcharset134 SimSun;}}{\\colortbl ;\\red0\\green0\\blue0;}\\viewkind4\\uc1\\pard\\cf1\\lang5124\\f0\\fs20\\'cc\\'d8\\par}" This is for the character 特 2.Now I convert the character values in to equavalant unicode number, which I got for this is 29305. 3.Now I want to convert this unicode number in to equavalant UTF-8 character. Can u suggest something with this scenerio . Regs

                Vineet Kumar Singhal Sr.Software Engineer Mumbai Tough Time Never last, but Tough People do.

                M 1 Reply Last reply
                0
                • V Vineet Kumar

                  Hi, I tried with that , but could not found the desired result. In fact the stepa which I followed are as: 1. First I got the characters in the rtf string for a character(say chinese) I typed. ex:\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\fmodern\\fprq6\\fcharset134 SimSun;}}{\\colortbl ;\\red0\\green0\\blue0;}\\viewkind4\\uc1\\pard\\cf1\\lang5124\\f0\\fs20\\'cc\\'d8\\par}" This is for the character 特 2.Now I convert the character values in to equavalant unicode number, which I got for this is 29305. 3.Now I want to convert this unicode number in to equavalant UTF-8 character. Can u suggest something with this scenerio . Regs

                  Vineet Kumar Singhal Sr.Software Engineer Mumbai Tough Time Never last, but Tough People do.

                  M Offline
                  M Offline
                  Michael Dunn
                  wrote on last edited by
                  #8

                  LPCWSTR wszUTF16 = L"\x7279";
                  char szUTF8[16] = {0};

                  WideCharToMultiByte(CP_UTF8, 0, wszUTF16, -1, szUTF8, 16, NULL, NULL);

                  --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

                  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