Special characters on MFC dialog form - visual-c++

I can see special characters ąęį when I do form design on static text label:
These character are changed while running:
If I set these characters in programming way I have:
How can I ensure that the correct characters are displayed instead of question marks as shown in the screenshot above?
UPD:
My project is Multi-Byte. I found that in another computer I can see special characters. Why?

You need to use Unicode character set for this to work correctly, and my guess is that you're using MBCS character set now.
You could change it in the project properties. Refer to this screenshot:
Visual studio editor is fully Unicode, meaning it could display such special characters as you type when you're designing the dialog. However, if your application is not built with Unicode support, it won't be able to display thsoe characters when it runs. Thich is why you see the ??? replacing the Unicode text when you run the application.

If you get different results on different computers this is obviously due to differences in system settings.
The setting that controls this is called "Language for non-Unicode programs", and can be found under Control Panel, Language, Change date, time or number formats. Unfortunately it's a global setting (ie cannot be set per application or programmatically) and requires a re-boot.
Consider making your application Unicode, if possible (and meaningful cost- or effort-wise).

Related

Previewing and Typing in Unicode font (Private Area / Basic Multilingual Plane) in Linux for SMuFL

I would like to make a change to an open source Android app which uses the Bravura font implementing the Standard Music Font Layout (SMuFL) fonts. I am developing on Linux.
The app displays musical notes with things like
<string name="notef_c5"> == ==</string>
which is displayed like
I now need to change things and I would like to see what I am going to do, rather than semi-randomly changing the Unicode numbers and see what happens. So I installed the font on my Linux desktop from github, by simply copying the SVG that the app is using into my global font directory and that did not work (fc-cache said /usr/share/fonts/svg/Bravura: caching, new cache contents: 0 fonts, 0 dirs). The same procedure for the OTF did work. This could be a problem down the line, since the app is using slightly modified version of the SVG, so any hint on that could help, but it's secondary regarding the question.
In fact I want to use "something" to display the font, and I tried many things, including Charmap and FontManager (which is almost the same as FontViewer). Charmap is the worst, displaying basically every single font installed on the machine even if I select just the Bravura (why is that???!) -- FontManager does the same (???!) -- FontViewer is almost passable, in that (when the "Characters" tab is selected) it display empty squares for the characters not defined in Bravura. Therefore with lots of careful scrolling it displays the "actual things" I am looking for, but it does not show their unicode values, and it's an extenuating search of few actual characters in a huge ocean of empty squares. So it's a no go anyway.
Is it possible that the best solution is just to blindly type Unicode values as described in the docs and see what happens? I know, if I were running Windows or Mac I could use Dorico SE but more generally there must be a better way of using Unicode in Linux, perhaps built for other purposes?
If you’re looking for specific symbols in the SMuFL specification, the full list of glyphs is available on the SMuFL website. (Note that the fonts themselves know nothing about music typesetting, they are simply collections of shapes to be used by a typesetting program. Even the simple example you provided is a composite of several carefully scaled and positioned glyphs, and simply changing the character codes may or may not work as intended.)
If you’re looking for ways to input Unicode characters on Linux, see the many suggestions provided here: How to type special characters in Linux?

MBCS File Menus generate ???? Characters

I am working on an MBCS app using MFC. I am trying to support Asian languages. For the purposes of this discussion, we'll say I'm trying to support Chinese. I am able to support Pop up dialogs via MessageBoxW and Dialog SCREENs by pasting Chinese characters directly into the RC file. I can't get file menus to work using either resource view or editing the RC file directly. Whenever I type in ANY Asian character, the screen shows ???. One ? for each character. I have tried modifying the menu in C++ using ModifyMenuW. I get more question marks. Visual Studio shows everything working, and the RC file is unicode (UTF-16). I can't easily convert my project to unicode mode. Spanish, French, and German all works fine (one of the Essets in German doesn't work, but that isn't a show stopper). What should I try next?
Thanks in advance!
Well, the easy answer would be change the application to Unicode, but this is not always simple, or possible at all.
Concerning using Unicode in a MBCS application, some things are possible and some others not. For example, I have made a MBCS application displaying and editing translations of program strings (messages, menues etc) in a ListView control, however ListView does have a specific message to turn it to Unicode (LVM_SETUNICODEFORMAT) and support operations (see also CCM_SETUNICODEFORMAT). Menus aren't controls though, but they do have "wide" (Unicode) functions.
If you want to use Unicode in your application, there are some tests you need to make. Success is not guaranteeded, but you can at least draw some conclusions and determine whether what you want to do is possible.
Test1:
You mentioned trying ModifyMenuW(), but this will try to modify an existing menu. Instead, try InsertMenuW() or InsertMenuItemW(). Any unicode string should be displayed properly, so try not just Chinese, but other laguages too (eg Greek or Russian). And btw, I can't see how French works and German doesn't (they use the same codepage - West European). What's the system codepage of your test-machine?
Test2: (if the above has failed)
Try changing the whole menu (SetMenu()) with having a single (unicode) menu item as its root.
Test3: (if the above have failed)
Then you need to check whether the window containing the menu must be Unicode. Create a simple "Hello World" Win32 application, or find a sample, if Visual Studio does not do this for you (these basically register the window class, create the main window and start the message-loop) - you must add a menu too, using the "wide" version of the menu functions explicitly. If this doesn't work, try changing the code that creates the window to unicode. This way you will know whether you need a unicode window, to own the menu.
Please make these tests and let us know the results. I will further post if needed.

Onenote 2016 box drawing characters are displayed as ⍰

I'm using MS Office 2016 One note on windows 10.
On my PC, when I put box-drawing characters as like this : ┴┻┷┸┸┵┶┹┺┐┐┘├┬┬┤┴┼┣┳┼ on OneNote 2016 on Windows 10 those will be shown as ⍰⍰⍰⍰⍰⍰⍰⍰⍰┐┐┘⍰⍰⍰⍰⍰⍰⍰⍰⍰. Some of these seem like a missing glyph, but some of those are displayed properly, I've changed fonts but I still get the same result. I've also tested it on different office 2016's products but this only occurred on OneNote 2016.
Any possible solutions?
The reason why this doesn't work has nothing to do with the fonts as you've found. OneNote simply doesn't support unicode as has been reported here and the same issue, but more generally can be found also in this article.
As the following excerpt about the Windows 10 Edition(but should mostly apply to other versions as well) explains, a font fallback system is used for most applications to help them display characters not in a font.
All Windows 10 editions include fonts that provide broad language support, and the Windows platform includes font fallback mechanisms designed to ensure that text in any language always displays with legible glyphs rather than boxes. But some apps may take direct dependencies on particular fonts for displaying certain Unicode characters and do not utilize the font fallback mechanisms provided by Windows 10 systems"
(emphasis mine)
However this explanation neglects how Windows actually uses fonts and why a font fallback is necessary. The way that most applications in Windows handle text is:
Find the font it wants. Depending on the application it might look for a font file that comes bundled with it, or looks for the font in the Windows Font Directory if it's a commonly used font.
Displays the characters the chosen font supports. This contains characters to display, but not all of them, as there are 137,174 Unicode Characters and designing a single font for all of them is impossible because a font file simply can't contain that many characters.
However there are font families that are attempting to do this such as Google Noto.
Uses "font fallbacks" if the application uses them to display unsupported unicode. Windows knows that no font file can support all Unicode Characters so it has a system that inserts fonts for different languages and sections of Unicode.
Older applications such as OneNote may support sections or languages of this in a more manual way, but ultimately doesn't use the font fallback system, and so doesn't support all Unicode Characters. Which leads to the next step
Windows displays the "not defined" glyph this usually has the appearance of a rectangular box as you've seen, this can be "overridden" in a font, and depending on the OS or even application may appear as a black question mark.
The reason why OneNote has so many of these font issues is because it is a legacy program. In fact, the version you have stated you use, OneNote 2016 is being Sunsetted and as such will not be getting any more updates, so there is likely no fix for this beyond using a different application.
Disclaimer: I am not an expert nor will I pretend to be, I hope that this represents an accurate explanation, but cannot guarantee it. I may turn this into a community wiki later, but I plan to research this topic more to verify it.

Automatic HTML escape sequences conversion from Design View to Code View

I have been searching on the web unsuccessfully for a Dreamweaver facility I know exists, and it's quite useful.
In Code View, for typing characters like "ç", we type &ccedil ; as the best practice. What I would like to know is how to be able to type a word that contains the character "ç" in the Design View and get it automatically escaped in the Code View, thus without requiring my own intervention to escape it.
Is that option present among the Dreamweaver preferences? I have not found it.
Thanks in advance!
There isn't an option in preferences to do this but Dreamweaver will do it if the Encoding is set to something other than UTF-8 or other encoding option that doesn't natively support the character.
Start a new, blank page and do Modify | Page Properties | Title/Encoding and change whatever is in the Encoding box to "Western European" and then paste the ç character. Switch to code view and you will see the encoded version. If your page is set to UTF-8, you'll see the ç character in both views.

apostrophes changes when I copy and paste

When I cut and paste apostrophes between programs (ie. notepad2, notepad++, hiedisql, word, etc etc) and wysiwyg's, and source codes my apostrophe is changing a little. It looks different and it behaves differently depending on the copy source and paste source.
Is this normal? Is there any way to make sure everything renders the apostrophe the same way? is this a windows thing?
I feel like this is a new thing, but maybe it has always been like this.
Do you mean that ’ -- should look like: -- turns into ' ??
If so, your editor program is "helpfully" changing a non-Ascii right apostrophe into the only apostrophe available in Ascii, the "straight" apostrophe: ' (Or vice-versa.)
The right and left apostrophes are defined in Unicode and ISO 8859 character sets, but not Ascii.
Solution Check the docs for your editors to see if you can turn off the behavior. It may not be possible depending on the specific editing software and its version.
Added Even this editor in Stack Overflow caused me some problems: I entered the Unicode right apostrophe, and it looked fine in the editor. But the preview window (and the display of my answer) shows the apostrophe as being a "straight" apostrophe: it appears that the font used by Chrome for displaying and previewing the answer shows a straight apostrophe instead of a right one. So I added a graphic for the right apostrophe.
Blog post about the problem
For writing software, SQL, etc, you should stick to the straight apostrophe. Editors should not convert the straight apostrophe to the right apostrophe. The issues of single quotes (apostrophes) and straight quotes vs opening and closing quotes is a primary difference between a document editor and a code (software) editor. If your editor changes apostrophes and quotes for you, it can cause a lot of problems in your software. You can usually turn off the behavior of "smart quotes" or similar.

Resources