Unicode sizeof(TCHAR) == 1???
-
I am building a dll that is supposed to be using Unicode but I am having some problems. I won't go into a lot of detail but here's a quick summary - I am using grid software that requires a CString to be passed into it's SetText() function. I have a structure that has the follwing member: struct MYSTRUCT{ TCHAR szDescription[512]; }; So, when I reach the point where I need to set my grid text, I use the following: CString szTxt(struct.szDescription); It fails indside the CString code in AllocBuffer() where it is actually doing the "new" call. I don't expect anyone to know how to solve this but one thing that jumps out at me is that when I type sizeof(TCHAR) into my watch window, it returns a value of 1. I was expecting 2. I have "UNICODE" and "_UNICODE" defined in the project settings. Any idea?
-
I am building a dll that is supposed to be using Unicode but I am having some problems. I won't go into a lot of detail but here's a quick summary - I am using grid software that requires a CString to be passed into it's SetText() function. I have a structure that has the follwing member: struct MYSTRUCT{ TCHAR szDescription[512]; }; So, when I reach the point where I need to set my grid text, I use the following: CString szTxt(struct.szDescription); It fails indside the CString code in AllocBuffer() where it is actually doing the "new" call. I don't expect anyone to know how to solve this but one thing that jumps out at me is that when I type sizeof(TCHAR) into my watch window, it returns a value of 1. I was expecting 2. I have "UNICODE" and "_UNICODE" defined in the project settings. Any idea?
Dave_ wrote: I don't expect anyone to know how to solve this but one thing that jumps out at me is that when I type sizeof(TCHAR) into my watch window, it returns a value of 1. I was expecting 2. I have "UNICODE" and "_UNICODE" defined in the project settings. Try placing
#define UNICODE
and#define _UNICODE
in thestdafx.h
file before any other#include
statements. It shouldn't matter if those directives are in the code or are in the project settings, but you never know...
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
I am building a dll that is supposed to be using Unicode but I am having some problems. I won't go into a lot of detail but here's a quick summary - I am using grid software that requires a CString to be passed into it's SetText() function. I have a structure that has the follwing member: struct MYSTRUCT{ TCHAR szDescription[512]; }; So, when I reach the point where I need to set my grid text, I use the following: CString szTxt(struct.szDescription); It fails indside the CString code in AllocBuffer() where it is actually doing the "new" call. I don't expect anyone to know how to solve this but one thing that jumps out at me is that when I type sizeof(TCHAR) into my watch window, it returns a value of 1. I was expecting 2. I have "UNICODE" and "_UNICODE" defined in the project settings. Any idea?
What is in
szDescription
at that point? Is it in Unicode? Is it properly null-terminated? --Mike-- LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD -
I am building a dll that is supposed to be using Unicode but I am having some problems. I won't go into a lot of detail but here's a quick summary - I am using grid software that requires a CString to be passed into it's SetText() function. I have a structure that has the follwing member: struct MYSTRUCT{ TCHAR szDescription[512]; }; So, when I reach the point where I need to set my grid text, I use the following: CString szTxt(struct.szDescription); It fails indside the CString code in AllocBuffer() where it is actually doing the "new" call. I don't expect anyone to know how to solve this but one thing that jumps out at me is that when I type sizeof(TCHAR) into my watch window, it returns a value of 1. I was expecting 2. I have "UNICODE" and "_UNICODE" defined in the project settings. Any idea?
Also, you might verify it is not the 'watch' window getting messed up, and do something like this in your (debug) build: size_t szTemp = sizeof(TCHAR); and quickwatch the value of szTemp. Is it 1 or 2? Just to double-check against a wierd anomaly in the watch window's expression parsing or something.