Question

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);
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top