[Win32utils-devel] Wide strings and LPCTSTR types
win32utils-devel at rubyforge.org
win32utils-devel at rubyforge.org
Wed Feb 25 09:44:21 EST 2004
All,
I was experimenting with converting LPCTSTR strings to wide strings with
something like this:
// Converts a Ruby string to a LPWSTR
LPCTSTR AllocWideLString(VALUE rbString){
char* str = STR2CSTR(rbString);
int length = (strlen(str)+1) * sizeof(WCHAR);
LPCTSTR lpStr = (LPCTSTR)malloc(length);
MultiByteToWideChar(
CP_ACP,
0,
str,
strlen(str)+1,
(LPWSTR)lpStr,
length
);
return lpStr;
}
But, that didn't seem to work very well in testing. Is there a better
way? Otherwise, I'll have to stick to casting for now.
Also, I noticed that there's a IsTextUnicode() function. Should I be
employing that somehow?
Dan
More information about the win32utils-devel
mailing list