Direct2D and DirectDraw how to draw characters from different language ?

Hello, I am using D2D1_1 api over Direct3D11_x. I am using win32 api. I can print any character from keyboard (EN, RU, ...other) on MessageBox. That works well with standard lantin characters "abcdef…@+?!123" However, when it comes to RU characters on direct2D drawing my program throw following error:
https://ibb.co/mTm44zG


I normally print it like this in MessageBox:

RESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam)
{
switch (umsg)
{
case WM_CHAR:
{

wchar_t text2 = LOWORD(wparam); //GETS pressed characters
MessageBox(hwnd, &text2, L"test", MB_OK);
}

...

Is that possible to render characters from different language packs on Direct2D or what should I do ?
 
MessageBoxW expects LPCWSTR, a pointer to a constant null-terminated string - you're passing a single character from WM_CHAR event.

Change your wchar_t declaration to a static array with an initializer
Code:
wchar_t text2[]= {LOWORD(wparam),'\0'};
and simply pass text2 as the second parameter (array name evaluates to a pointer in C/C++).


As for error message
Code:
Debug assert failed
Program: C:\ ... exe
File: minkernel\crts\ucrt\src\appcnt\convert\isctype.cpp
Expression:
c >= -1 && c <= 255
it's probably related to invalid UTF to ASCII conversion elsewhere in your code. If you Google search this message, it also emerges as a Visual C++ runtime library debug condition for "string array out of bounds" error.

It's a pity C++ is so terrible at runtime debug messages, and it's not going to change much until at least C++26 (i.e. P0709 deterministic exceptions and similar proposals detailed at CppCon sessions).
 
Last edited:
Back
Top