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. Convert char string to UTF-8

Convert char string to UTF-8

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 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.
  • K Offline
    K Offline
    kcynic
    wrote on last edited by
    #1

    I want to convert char[] string to UTF-8. How should I use int MultiByteToWideChar() and WideCharToMultiByte() to do such convertion? And if I should not use the two function to resolve such task,but how should I do? Thanks. GOOD LUCK

    F K 2 Replies Last reply
    0
    • K kcynic

      I want to convert char[] string to UTF-8. How should I use int MultiByteToWideChar() and WideCharToMultiByte() to do such convertion? And if I should not use the two function to resolve such task,but how should I do? Thanks. GOOD LUCK

      F Offline
      F Offline
      fefe wyx
      wrote on last edited by
      #2

      First use MultiByteToWideChar() to convert the char string from your local code page to wide char, then use WideCharToMultiByte() to convert the wide char string to UTF8. You may use CP_ACP for your local code page, and code page for utf-8 is 1200. But I've never tried the conversion between wide char and utf-8, so I'm not sure whether it would succeed.

      K 1 Reply Last reply
      0
      • K kcynic

        I want to convert char[] string to UTF-8. How should I use int MultiByteToWideChar() and WideCharToMultiByte() to do such convertion? And if I should not use the two function to resolve such task,but how should I do? Thanks. GOOD LUCK

        K Offline
        K Offline
        KarstenK
        wrote on last edited by
        #3

        it is good style to use the API-functions, because they do really a good job in checking different parameters and conditions. But they are hungry for parameters. X|

        Greetings from Germany

        1 Reply Last reply
        0
        • F fefe wyx

          First use MultiByteToWideChar() to convert the char string from your local code page to wide char, then use WideCharToMultiByte() to convert the wide char string to UTF8. You may use CP_ACP for your local code page, and code page for utf-8 is 1200. But I've never tried the conversion between wide char and utf-8, so I'm not sure whether it would succeed.

          K Offline
          K Offline
          kcynic
          wrote on last edited by
          #4

          I also do not want to convert the string to UTF-8.But I use the "libipod"(a opensource code of iPod),it use utf-8 and utf-16!

          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