What is the simplest way to convert char[] to/from tchar[] in C/C++(ms)?

后端 未结 8 968
遥遥无期
遥遥无期 2020-12-03 17:02

This seems like a pretty softball question, but I always have a hard time looking up this function because there seem there are so many variations regarding the referencing

相关标签:
8条回答
  • 2020-12-03 17:57

    TCHAR is a Microsoft-specific typedef for either char or wchar_t (a wide character).

    Conversion to char depends on which of these it actually is. If TCHAR is actually a char, then you can do a simple cast, but if it is truly a wchar_t, you'll need a routine to convert between character sets. See the function MultiByteToWideChar()

    0 讨论(0)
  • 2020-12-03 17:58

    The simplest way is to use the conversion macros:

    • CW2A
    • CA2W
    • etc...

    MSDN

    0 讨论(0)
提交回复
热议问题