CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2010
    Posts
    74

    how to convert TCHAR[] to const char[]

    hi all,
    please tell me how to convert TCHAR[] to const char[].


    thanks,
    rohit negi

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: how to convert TCHAR[] to const char[]

    Why is this an issue? Are you trying to link with some third party lib? If so, the easiest way is to set your project to MBCS instead of unicode.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: how to convert TCHAR[] to const char[]

    Is your project set to Unicode or MBCS?
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  4. #4
    Join Date
    Jul 2006
    Posts
    203

    Re: how to convert TCHAR[] to const char[]

    to convert TCHAR[] to char[] there is a function WideCharToMultiByte. It depends on locale.

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: how to convert TCHAR[] to const char[]

    Quote Originally Posted by MFCQuery
    there is a function WideCharToMultiByte. It depends on locale.
    To use it or not, it depends on
    Quote Originally Posted by Marc G
    Is your project set to Unicode or MBCS?
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured