Чем отличается tchar от wchar
Перейти к содержимому

Чем отличается tchar от wchar

  • автор:

tchar.h on linux

I am trying to write cross platform i18n C++ code. Since most linux system prefer to use UTF-8 as the character encoding, I thought that I should use string on linux and wstring on Windows. Is tchar.h available on linux? What is an equivalent replacement on for tchar.h on Linux?

39.3k 3 3 gold badges 78 78 silver badges 117 117 bronze badges
asked May 21, 2009 at 23:37
273 1 1 gold badge 3 3 silver badges 6 6 bronze badges

2 Answers 2

You may find this article to be useful. In particular, near the end they discuss a bit about using TCHAR and dealing with Windows code.

The article summarization is:

TCHAR will be translated into a wide character data type when compiling this code with the GNU C Compiler (most portable libraries define TCHAR in their headers and refer to wchar_t). This, in fact, was how I turned my C++ program into an anagram generator: I used standard C++ strings filled with UTF-8 and fed the data with pointers casted to wchar_t to library functions. UTF-8 data interpreted as UTF-32 equals garbage (but it is tremendously useful for obfuscation of data and bugs).

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *