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 to convert TCHAR to char

How to convert TCHAR to char

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structurestutorial
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.
  • T Offline
    T Offline
    transoft
    wrote on last edited by
    #1

    Hi I have a unicode string. I want to convert it to char array. How can I do it? Thanks

    W T R 3 Replies Last reply
    0
    • T transoft

      Hi I have a unicode string. I want to convert it to char array. How can I do it? Thanks

      W Offline
      W Offline
      willy_total
      wrote on last edited by
      #2

      char *pAnsiString = new char[nSize+1]; wcstombs(pAnsiString, wcpString, nSize+1);

      1 Reply Last reply
      0
      • T transoft

        Hi I have a unicode string. I want to convert it to char array. How can I do it? Thanks

        T Offline
        T Offline
        try88
        wrote on last edited by
        #3

        int MultiBytetoWideChar(....) look up the MSDN for detail 路漫漫其修远兮,吾将上下而求索。

        1 Reply Last reply
        0
        • T transoft

          Hi I have a unicode string. I want to convert it to char array. How can I do it? Thanks

          R Offline
          R Offline
          Ryan Binns
          wrote on last edited by
          #4

          Do you have a unicode string, or a TCHAR string? If it's a TCHAR, use the ATL T2A() macro, as it will work correctly regardless of whether you're compiling for unicode or not. If it's a true unicode string (using WCHAR), use the WideCharToMultiByte() function.

          Ryan

          "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

          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