开发者

TextOut() doesn't seem to exhibit a surrogate UNICODE pair

开发者 https://www.devze.com 2023-03-01 12:05 出处:网络
I tried to exhibit U+1D400 (surrogate pair H = 0xD835 L = 0xDC00) using TextOut() to no avail. Why ?

I tried to exhibit U+1D400 (surrogate pair H = 0xD835 L = 0xDC00) using TextOut() to no avail. Why ?

case WM_PAINT:

    PAINTSTRUCT ps;

    BeginPaint(hwnd, &ps);

    int iLogPixelsY;

    iLogPixelsY = GetDeviceCaps(ps.hdc, LOGPIXELSY);

    LOGFONT lf;

    int iPts;

    iPts = 11;

    memset(&lf, 0, sizeof(LOGFONT));
    lf.lfHeight = -iPts * iLogPixelsY / 72;
    lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
    wcscpy_s(lf.lfFaceName, L"Cambria Math");

    HFONT hFont;

    hFont = CreateFontIndirect(&lf);
    hFont = (HFONT)SelectObject(ps.hdc, hFont);

    wchar_t tx[2];

    tx[0] = 0xD835;
    tx[1] = 0xDC00;

    TextOut(ps.hdc, 10, 100, tx, 1); 

    DeleteObject(SelectObject(ps.hdc, hFont));

    EndPaint(hwnd, &ps)开发者_开发技巧;
    break;


You are calling TextOut specifying a string length of 1, but according to this documentation, you should pass 2 since it is a surrogate pair.

0

精彩评论

暂无评论...
验证码 换一张
取 消