Questions tagged [tchar]

A #define for either char or wchar_t, used for porting ancient windows applications

TCHAR and related preprocessor-defines are used in two places:

  1. Porting ancient windows application to modern UTF-16 APIs.
  2. Describing APIs available in both ANSI and UTF-16 flavor.

If neither of the above fits for you, you really should not be using it:
Is TCHAR still relevant?

#ifdef _UNICODE
    #define TCHAR wchar_t
    // many others
#else
    #define TCHAR char
    // many others
#endif
164 questions
7
votes
3 answers

How to deal with Unicode strings in C/C++ in a cross-platform friendly way?

On platforms different than Windows you could easily use char * strings and treat them as UTF-8. The problem is that on Windows you are required to accept and send messages using wchar* strings (W). If you'll use the ANSI functions (A) you will not…
sorin
  • 161,544
  • 178
  • 535
  • 806
6
votes
3 answers

C++ Combine 2 Tchar

I'm trying to combine 2 tchar. char username[UNLEN+1]; DWORD username_len = UNLEN+1; GetUserName(username, &username_len); TCHAR* appdatapath ="C:\\Users\\"+username+"\\AppData"; But I get error error at appdatapath line. How can I combine 2 tchar?…
backspace
  • 299
  • 2
  • 3
  • 7
6
votes
3 answers

Converting _TCHAR* to char*

I'm trying to get a simple OpenCV sample working in C++ on Windows and my C++ is more than rusty. The sample is fairly simple: #include #include #include using namespace cv; using…
dumbledad
  • 16,305
  • 23
  • 120
  • 273
5
votes
2 answers

tchar.h not found on cygwin

I'm running the latest cygwin on windows 7 (32-bit), and trying to build an open-source project, RtAudio (it doesn't currently build on this platform). One of the problems I've worked around is an error on the line #include . My build…
Jason Sundram
  • 12,225
  • 19
  • 71
  • 86
5
votes
4 answers

How can I substring a TCHAR

I have a TCHAR and value as below: TCHAR szDestPathRoot[MAX_PATH]="String This"; Now I want the 1st three character from TCHAR , like below: szDestPathRoot.substring(0,2); How can I do this.
Simsons
  • 12,295
  • 42
  • 153
  • 269
5
votes
2 answers

C - Split TCHAR

How can I split a TCHAR into other variables? Example: TCHAR comando[50], arg1[50], arg2[50]; Mensagem msg; _tcscpy(msg.texto, TEXT("MOVE 10 12")); So, msg.texto has the string "MOVE 10 12" and I want the variable comando[50] to be "MOVE", the…
user3088049
  • 91
  • 1
  • 8
5
votes
2 answers

Comparing two TCHAR's with same value results false

I am trying to check my applications path, and if it is not a specified path, then move it. I feel like my code is solid, yet it does not work properly. TCHAR pCheck[MAX_PATH]; TCHAR…
Josh Line
  • 625
  • 3
  • 13
  • 27
4
votes
2 answers

How to open a file using _TCHAR* as a file name? c/c++

My main has the following signature: int _tmain(int argc, _TCHAR* argv[]) I would like to preform the following: FILE *inputFilePtr; inputFilePtr = fopen(argv[2], "_r"); But there is a type mismatch. How should I do it? Should I use: inputFilePtr…
M.N
  • 333
  • 3
  • 9
4
votes
3 answers

Visual Studio 2010 Arduino cpp Error: argument of type "char *" is incompatible with parameter of type "LPCWSTR"

I'm trying to set up an arduino uno for serial port communication with a C++ program in visual studio 2010. I'm working from the code found here: http://playground.arduino.cc/Interfacing/CPPWindows Unfortunately, the .cpp file gives me the following…
X__
  • 89
  • 2
  • 8
4
votes
2 answers

Convert char to TCHAR* argv[]

How can I input text into TCHAR* argv[]? OR: How can I convert from char to TCHAR* argv[]? char randcount[] = "Hello world"; TCHAR* argv[]; argv = convert(randcount);
Sijith
  • 3,740
  • 17
  • 61
  • 101
4
votes
4 answers

How do I convert a "pointer to const TCHAR" to a "std::string"?

I have a class which returns a typed pointer to a "const TCHAR". I need to convert it to a std::string but I have not found a way to make this happen. Can anyone provide some insight on how to convert it?
TERACytE
  • 7,553
  • 13
  • 75
  • 111
4
votes
6 answers

How to convert std::wstring to a TCHAR*?

How to convert a std::wstring to a TCHAR*? std::wstring.c_str() does not work since it returns a wchar_t*. How do I get from wchar_t* to TCHAR*, or from std::wstring to TCHAR*?
esac
  • 24,099
  • 38
  • 122
  • 179
4
votes
3 answers

How to convert char* to TCHAR[ ]?

char* stheParameterFileName = argv[1]; //I'm passing the file name as a parameter. TCHAR szName [512]; How can I convert char* to TCHAR []?
parth patel
  • 435
  • 2
  • 6
  • 15
4
votes
3 answers

`cout << argv[0]` returning hex value?

Possible Duplicate: Can not print out the argv[] values using std::cout in VC++ Code: using namespace std; int _tmain(int argc, _TCHAR* argv[]) { cout << argv[0] << endl; system("PAUSE"); return 0; } As you can see, a standard Win32…
Nate Koppenhaver
  • 1,676
  • 3
  • 21
  • 31
3
votes
3 answers

Handling TCHARs in header files for libraries with different character sets

I have a project that uses two third party libraries, both of which make use of TCHARs in their header files. Unfortunately one library is complied as multi-byte (call it library a), and the other is compiled as Unicode (call it library b). Now the…
MichaC
  • 2,834
  • 2
  • 20
  • 20
1
2
3
10 11