German characters are displayed incorrectly with SetDlgItemText

793 views Asked by At

I read a german text from an sqlite database with C++, (the text looks good with the database viewer). But when I display it in a dialog with SetDlgItemText the text looks like this (see the picture).

enter image description here

    CString strWarning(pStmt->GetColumnCString(nCol));      
    SetDlgItemText(IDC_WARNING_MESSAGE, strWarning);
1

There are 1 answers

2
Collin Dauphinee On BEST ANSWER

Your string looks like it's encoded as UTF-8, which Windows doesn't handle.

You'll need to convert it to UTF-16 and ensure that you're calling the wide version of SetDlgItemText, either by changing your project's character set option to Use Unicode Character Set or specifying SetDlgItemTextW.

You can convert your string from UTF-8 to UTF-16 with the MultiByteToWideChar function.