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 do i convert unicode string to ansi format?

how do i convert unicode string to ansi format?

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

    i have string that may contain unicode character,i want to write that strings into text file,replacing unicode character with unicode values

    H A 2 Replies Last reply
    0
    • Y yogish293

      i have string that may contain unicode character,i want to write that strings into text file,replacing unicode character with unicode values

      H Offline
      H Offline
      Hans Dietrich
      wrote on last edited by
      #2

      By far the simplest way: TN059: Using MFC MBCS/Unicode Conversion Macros.

      Best wishes, Hans


      [Hans Dietrich Software]

      1 Reply Last reply
      0
      • Y yogish293

        i have string that may contain unicode character,i want to write that strings into text file,replacing unicode character with unicode values

        A Offline
        A Offline
        Alain Rist
        wrote on last edited by
        #3

        Hi, I suppose you want something like this (C++):

        #include <sstream>
        #include <iterator>
        size_t OutputByteVals(const std::wstring ws, std::ostream& out)
        {
        const size_t nBytes = ws.size() * sizeof(wchar_t);
        std::copy_n(reinterpret_cast<const char *>(ws.data()), nBytes , std::ostream_iterator<int>(out, " "));
        return nBytes;
        }

        cheers, AR

        When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)

        modified on Wednesday, March 2, 2011 3:22 AM

        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