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);
有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top