How to display Japanese characters in VBA editor? - excel

I can't set Sheet.Name property in Japanese. Event file name also displays in maybe Chinese? All display well in Excel.
How can I set up the VBA editor to work with Japanese?
I changed region to Japanese.

Finally, I got to the right point.
this post is in Japanese but by picture so not hard to see that in Admitration we must uncheck [Header: World Wide language support ... use Unicode UTF-8]
maybe as #stifin mentioned, it is about wide character.
Answer

Related

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.

Special characters on MFC dialog form

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).

Displaying Japanese text in the Immediate Window of Excel VBA

In Excel 2010, I have a worksheet containing Japanese text. There is no problem editing, or displaying this. When I grab the value of a cell containing Japanese and use Debug.Print to display it in the Immediate Window it appears as ???? This would be a familiar issue if I was dealing with a browser. I would just make sure everything was in UTF-8 encoding. I have Japanese installed on my English Windows and that's all working fine. In Excel I tried to set the default language to Japanese. I changed the editor font to Arial Unicode but so far I still get question marks. I contacted Microsoft. I was passed from one person to another, but they couldn't help. They offered to pass me to a Technical support person who would charge me 500 US dollars!
How can I debug Japanese values in an English version of Excel using the Immediate Window?
The VBA development environment depends on the Windows "system locale" setting to tell it what character set to use. I got it to work using
Windows Vista (English)
Excel 2010 (English)
by going into the "Regional and Language Options" section of the Windows Control Panel and setting the system locale to "Japanese (Japan)"
After my system rebooted I could see Japanese characters in the VBA Immediate Window:

Place subscripts in a QString

I'm having a difficult time finding how to insert subscripts into a QString. I know it can be done with style sheets, but I can't really use a style sheet in places where I place a QString. I've tried HTML markup and UTF-8 and other unicode systems for substrings with no luck.
Hopefully someone has some more experience with this and can help out!
Depending on what characters you want to subscript, you may be able to use Unicode subscript characters without formatting.
That of course requires font and text rendering engine that support it. Don't know if Qt on your platform does.
A QString is just a string. If you're dealing with particular Unicode characters which should be subscript then fine, but otherwise what you seem to be trying to do makes no sense.
If you want to display a string with subscript formatting then you can use QTextEdit or other classes which support rich text display. You could do this with HTML markup or programatically using the relevant Qt classes. Try http://qt-project.org/doc/qt-4.8/richtext.html for more information.

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