Is it possible to use a Unicode “argv”?

后端 未结 6 988
南旧
南旧 2021-02-07 09:48

I\'m writing a little wrapper for an application that uses files as arguments.

The wrapper needs to be in Unicode, so I\'m using wchar_t for the characters and strings I

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-07 10:14

    On Windows, you can use tchar.h and _tmain, which will be turned into wmain if the _UNICODE symbol is defined at compile time, or main otherwise. TCHAR *argv[] will similarly be expanded to WCHAR * argv[] if unicode is defined, and char * argv[] if not.

    If you want to have your main method work cross platform, you can define your own macros to the same effect.

    TCHAR.h contains a number of convenience macros for conversion between wchar and char.

提交回复
热议问题