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. utf-8

utf-8

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

    Can you tell me the function to convert ansi string to utf-8 string?

    D V H 3 Replies Last reply
    0
    • C cuongcntt2002

      Can you tell me the function to convert ansi string to utf-8 string?

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Have you tried MultiByteToWideChar() or WideCharToMultiByte()?


      "The largest fire starts but with the smallest spark." - David Crow

      "Judge not by the eye but by the heart." - Native American Proverb

      1 Reply Last reply
      0
      • C cuongcntt2002

        Can you tell me the function to convert ansi string to utf-8 string?

        V Offline
        V Offline
        Viorel
        wrote on last edited by
        #3

        If no other solutions, I think you can try successive calls of MultiByteToWideChar and WideCharToMultiByte. First call converts the ANSI string to Unicode format, and then the second call converts to UTF-8 format:

        char ansi[] = "Ansi String";
        wchar_t unicode[100];
        char utf8[100];
        
        MultiByteToWideChar(CP_ACP, 0, ansi, -1, unicode, 100);
        WideCharToMultiByte(CP_UTF8, 0, unicode, -1, utf8, 100, NULL, NULL);
        

        Hope it works.

        1 Reply Last reply
        0
        • C cuongcntt2002

          Can you tell me the function to convert ansi string to utf-8 string?

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          See Here[^] maybe it is some helpful to you_**


          **_

          whitesky


          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