Note that there are some explanatory texts on larger screens.

plurals
  1. PORussian characters not showing up correctly in MFC unicode list box
    primarykey
    data
    text
    <p>I have an MFC application compiled with MBCS set.</p> <p>I have created a unicode list box on a regular MBCS dialog using the following code:</p> <pre><code>DWORD dwStyle = WS_CHILD|WS_VISIBLE|WS_VSCROLL; hLangListBox = CreateWindowExW(WS_EX_CLIENTEDGE, //extended styles _T(L"listbox"), //control 'class' name L"Language", //control caption dwStyle, //control style 10, //position: left 10, //position: top 200, //width 100, //height GetSafeHwnd(), //parent window handle //control's ID reinterpret_cast&lt;HMENU&gt;(static_cast&lt;INT_PTR&gt;(ID_LANGUAGE_ENGLISH+20)), AfxGetInstanceHandle(), //application instance 0); </code></pre> <p>When I inspect this dialog using Spy++ I see my Window Proc: has (Unicode) so I believe it is being created correctly.</p> <p>I am populating the listbox with one of the following commands depending on if I have the data in a unicode string or a regular string</p> <pre><code>CStringW m_LanguageNames[MAX_LANG]; CString sFilename; .... ::SendMessageW(hLangListBox,LB_INSERTSTRING ,nMenuPos,reinterpret_cast&lt;LPARAM&gt;(theApp.m_LanguageNames[i].GetBuffer())); ::SendMessage(hLangListBox,LB_INSERTSTRING ,nMenuPos,reinterpret_cast&lt;LPARAM&gt;(sFileName.GetBuffer())); </code></pre> <p>Things look ok for most entries, </p> <p>I can see </p> <p>Chinese: 中文(简体)</p> <p>French: Française</p> <p>Japanese: 日本 </p> <p>but Russian looks like a P followed by a bunch of bars (P||||||), not Pусский. When I look at the contents of the CStringW in Visual Studio I do see the correct text.</p> <p>Why can I see the other languages correctly and not russian? I am running on Windows 7 ultimate and compiling with Visual Studio 10</p> <p><strong>Edit</strong></p> <p>If I change my system locale to Russian I can see the russian characters fine. However, the ç in Française does not appear correct.</p> <p>I thought unicode strings were independent of the system locale. Is that correct?</p> <p>To populate my unicode CStringW I am doing:</p> <pre><code>CA2W tmp_wide(po.msgstr,CodePage); m_LanguageNames[i] = tmp_wide; </code></pre> <p>where po.msgstr is a CString that was read in from a file. In this case, CodePage is set to 1251</p> <p>If I inspect the variables in Visual Studio it appears that the conversion is happening correctly.</p> <p>It appears that my unicode list box can display unicode characters from a MBCS such as Chinese fine, but that it can't display unicode characters from a SBCS that is different from my current code page.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload