Direct2D and DirectDraw how to draw characters from different language ?

Discussion in 'PC Hardware, Software and Displays' started by gomi, Apr 21, 2020.

  1. gomi

    Apr 21, 2020
    Likes Received:
    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:

    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 ?
  2. DmitryKo


    Feb 26, 2002
    Likes Received:
    55°38′33″ N, 37°28′37″ E
    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
    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
    Debug assert failed
    Program: C:\ ... exe
    File: minkernel\crts\ucrt\src\appcnt\convert\isctype.cpp
    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).
    #2 DmitryKo, Apr 22, 2020
    Last edited: Apr 26, 2020

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.