News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Problem in displaying WCHAR

Started by vraifreud, October 03, 2007, 08:38:32 AM

Previous topic - Next topic

vraifreud

Hello!
Here's part of my program displaying a WCHAR string:

...
szStr word 0030h,0031h,0032h,0033h,0000h
...
invoke TextOut, hdc, x, y, addr szStr, 4
...

The String Displayed is "0??" where "?" is a char that I cannot type, while I expect it to be "0123". What is the problem? Thanks.

Tedd

"TextOut" is actually a shortcut to "TextOutA" which will assume the text you give it is ansi - use "TextOutW" explicitly.
(The same goes for most other function that have string parameters.)
No snowflake in an avalanche feels responsible.

u

To identify which API have both an ANSI and Widechar versions, simply look-out for paremeters of type:
LPCTSTR and LPTSTR . (Long Pointer to [Constant] Template STRing). The "Template" part means that there are 2 versions of the function. Internally in Win2k and later, for these API, ANSI strings get converted to Widechar.

LPTSTR is either a LPSTR (ANSI) or LPWSTR (Widechar).
LPCTSTR is either a LPCSTR or LPCWSTR

In C/C++ projects, at compile-time the windows.h header-files specify for each of those duplicated functions:
#ifdef _UNICODE
   #define TextOut  TextOutW
#else
   #define TextOut  TextOutA
#endif

You manually define _UNICODE in your .c/.h files, or set the project-options for compilation to pass a pre-define of _UNICODE on the command-line of the compiler.
Please use a smaller graphic in your signature.