WriteConsole () weird characters?

I use this snippet to create a fron console inside a dll. This dll is loading into the game.

CODE SNIPPET

The console window creates a penalty. But when I write the material, I just get things like "??? D ??".

I know that I need to use printf () syntax. Therefore i use

wprintf("%s", "test");

Any pointers?

+3
source share
5 answers

Try using:

wprintf(L"%s", "test");

since wprintf takes a string of characters as input

Edit : based on the fact that the behavior of% s and% S changes when used in wprintf, about which:

wprintf("%s", L"test");

% s wprintf , L "test".
"L" , wprintf :

int wprintf(char *fmt, ...)
+3

wprintf(), "" printf(). "" , "% s" :

printf() - "% s" , , "% S" -

wprintf() - "% s" , , "% S" ,

, wprintf() , , :

printf("%s", "test");
+1

_T(), , ASCII L, UNICODE. _t , , , ASCII w UNICODE. , , :

_tprintf(_T("%s"),_T("test");
+1

"% s" wprintf, .

, TCHAR:

LPCTSTR pName = _T("World");
_tprintf( _T("%s, %s"), _T("Hello"), pName );
0

Your encoding is incorrect, as you use wstring characters, but probably only have the ascii console. Make sure you use the Unicode font in the console.

-1
source

Source: https://habr.com/ru/post/1712000/


All Articles