Russian characters not showing up correctly in MFC unicode list box - unicode

I have an MFC application compiled with MBCS set.
I have created a unicode list box on a regular MBCS dialog using the following 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<HMENU>(static_cast<INT_PTR>(ID_LANGUAGE_ENGLISH+20)),
AfxGetInstanceHandle(), //application instance
0);
When I inspect this dialog using Spy++ I see my Window Proc: has (Unicode) so I believe it is being created correctly.
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
CStringW m_LanguageNames[MAX_LANG];
CString sFilename;
....
::SendMessageW(hLangListBox,LB_INSERTSTRING ,nMenuPos,reinterpret_cast<LPARAM>(theApp.m_LanguageNames[i].GetBuffer()));
::SendMessage(hLangListBox,LB_INSERTSTRING ,nMenuPos,reinterpret_cast<LPARAM>(sFileName.GetBuffer()));
Things look ok for most entries,
I can see
Chinese: 中文(简体)
French: Française
Japanese: 日本
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.
Why can I see the other languages correctly and not russian? I am running on Windows 7 ultimate and compiling with Visual Studio 10
Edit
If I change my system locale to Russian I can see the russian characters fine. However, the ç in Française does not appear correct.
I thought unicode strings were independent of the system locale. Is that correct?
To populate my unicode CStringW I am doing:
CA2W tmp_wide(po.msgstr,CodePage);
m_LanguageNames[i] = tmp_wide;
where po.msgstr is a CString that was read in from a file. In this case, CodePage is set to 1251
If I inspect the variables in Visual Studio it appears that the conversion is happening correctly.
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.

Same problem, solved after a long time.
In my case the default font of dialog is set to "MS Sans Serif", just change to use the more recent font "Microsoft Sans Serif" and everything is resolved!

I have not solved this yet, but I think it is likely this is a font issue. I'm not going any farther with this, but the next step would be to have an owner drawn list box and specify an appropriate font for each language

Related

Fix issue With VS Code: yellow orange border box around characters

When I type a ا letter in the Arabic language it is surrounded with a colored border box in vscode.
Any solution to this problem?
Your specific case - a series of Arabic characters - might no longer be highlighted in vscode (even with the following settings enabled) as vscode is getting a little smarter about strings of characters it would otherwise highlight.
Contextual Unicode Highlighting
To report fewer false positives, ambiguous and invisible unicode
characters are no longer highlighted if the surrounding characters
visually indicate a non-ASCII script.
Thus, in trusted workspaces, only characters that are invisible or can
be confused with ASCII characters are highlighted, except those that
are contained in a word of non-ASCII characters where at least one
character cannot be confused with an ASCII character.
from v1.65 Release notes; contextual unicode highlighting
Try disabling one or more of these settings (set to false):
Editor > Unicode Highlight: Non Basic ASCII
Editor > Unicode Highlight: Ambiguous Characters
also see https://stackoverflow.com/a/70293571/836330 for more on the Unicode Highlighting options. And https://stackoverflow.com/a/70297896/836330 and https://github.com/microsoft/vscode/issues/138767.
There is also a way in vscode v1.64 to add another locale to your environment so that its characters will not be highlighted as questionable unicode characters.
New setting: Editor > Unicode Highlight: Allowed Locales
Use this when your display language is something other than the language you are using in your files, like French, Russian, Japanese, etc. that is causing the unwanted unicode warning highlights.
Download the language pack you need:
Search in the Extensions view for "language packs". I believe only the Microsoft language packs are supported in the Allowed Locales at this time. The picture above shows the French Language Pack. Install it.
Add its language code to the Allowed Locales setting.
To find the right "code", the easiest is to open your Command Palette after installing the language pack and search for Configure Display Language. You don't want to change your display language but it will show the available language codes:
We see we need fr as the code.
It will make a setting like this in your settings.json:
"editor.unicodeHighlight.allowedLocales": {
"fr": true
}
Before these changes:
After: In theory, with the default options for the other unicode highlight setting, the unicode highlighting should be gone.
[It still seems a little rough to me, you may have different results.]

How VSCode choose the font from the given font list in editor.fontfamily?

When I open the VSCode editor.fontfamily setting, I found there is a list of font family in the input field. So I want to know that how VSCode choose the font from the given font list in editor.fontfamily?
Does it choose font following descended priority, and what is the stategy? Or the font in different locations have different effects?
Thanks.
The "list" is more of a set of fonts, where the first one is the preferred font, the next one being a fallback, and so on. It's not an actual list as far as a JSON object goes, it's just a string that's comma delimited.
{
"editor.fontFamily": "Consolas, 'Courier New', monospace",
// first second third
}
You can test this out by simply switching around the fonts and saving the file to see how Visual Studio Code reacts. If you put in a bogus font name as the first item in the set, when Visual Studio Code can't find the font, it will fallback to the next one. On Windows, if you supply nothing but invalid fonts, it looks like the ultimate fallback is Times New Roman (or an extremely similar looking font):

Alignment of characters in Notepad++

I just wondered why my m-files from MATLAB look so different when I open them with Notepad++ instead of the built-in MATLAB Editor.
It seems that in the MATLAB Editor each character has the same width. Not so in Notepad++ (even I change the language to "M").
Here's a screenshot from a file opened in Notepad++ (left) and in the MATLAB Editor (right).
In the MATLAB Editor all the characters in column X are exactly one below the other. They aren't in Notepad++.
I just played a bit with the tab preferences, without any success.
Is there a way to get the alignment of columns in Notepad++ the same as in the MATLAB Editor ...at least for m-files?
It's because your MATLAB Editor is set to use a monospaced font such as Courier (i.e. a font where all the characters are designed to have exactly the same width), but your Notepad++ is not.
In Notepad++, you can set the font with the menu Settings -> Style Configurator. Select "MATLAB" from the language list (or in fact you may like to select "Global Styles", to do this for all languages), and set the font to a monospaced font such as Courier.
Alternatively, you may like to download a more modern programming font such as Consolas, ProFont, Monofur, Proggy, or Inconsolata. These are all monospaced, and nicer than Courier. You can use the in both Notepad++ and the MATLAB Editor.
It's possible that another issue might be that you have tab characters in your code, which are displaying with a variable width in Notepad++. You can make sure that MATLAB replaces tab characters with spaces in the MATLAB preferences (MATLAB->Editor/Debugger/Tab). To check whether you have tab characters, open the file in Notepad++ and select View->Show Symbol->Show All Characters. Tab characters will display as a short arrow, and space characters will display as a little dot. If you need to change all the tabs to spaces in an existing file, Notepad++ can do this with Edit->Blank Operations->Tab to Space.
Hope that helps!
To add to Sam's answer, choosing a monospaced font specific to your environment's language is recommended. For instance, Courier New on Japanese language may not have the desired result. Choose MS Gothic (for Windows) or Osaka (for Mac) instead.

Mongo shell in Windows 7 "unicode text could not be correctly displayed"

I am using Windows 7 64 bit and I have English and Greek language installed for my keyboard.
If I switch to mongo shell and I try to write a UTF Greek character, I get this error
"Unicode text could not be correctly displayed.
Please change your console font to a Unicode font (e.g. Lucida Console)."
and it exits from the mongo shell.
Also when I type db.names.find() it displays the contents of the names collection but the UTF characters are messed up.
I can write UTF characters in regular cmd prompt without problems.
I solved this problem for my system by doing this procedure and changing font to Lucida Console. Before that it was set to Raster Fonts.
Open cmd
Right-click on the title bar
Choose Properties
Select the Font tab and from there choose the Lucida Console font and press ok.

setting Hex character for page break in Notepad

I have set Hexa character Hex(12) in program output for page break to a old printer alignment. When open the output text file with Notepad, the Hex'oc' will show as small male symbol (with small circal and a plus sign bottom). But some Notepad show as small square box for the same page break symbol.
The printing alignment is OK when using Notepad with small male symbol. However the printing alignment is not OK when using Notepad with small square box symbol.
BTW, I am using MS Window XP Pro version 2002 service pack 3.
Can anyboby help me on this ??
Thanks.
You mean this ♀ "female sign"?
The may be editors which switch to unicode whn discovering such symbols. Then your printer might get different data.
Another reason is the type of printer and driver:
There are drivers which just send what dots have to be drawn on the paper, others just send the text an dthe printer does it itself.
You wrote Notepad twice, do you mean the same native windows program?
What versions does it have?
If I go on "Help" > "About" it is printed: Version 6.1.7601