Click here to Skip to main content
15,860,972 members
Articles / Programming Languages / C++
Article

How to test your programs with Unicode characters in multiple languages on Windows 2000

Rate me:
Please Sign up or sign in to vote.
3.00/5 (3 votes)
27 Jan 2000 163.6K   64   18
How to test your Unicode program with foreign-language characters on Windows 2000

Windows 2000 makes it really easy to enter Unicode characters from other languages using IMEs (input method editors) and the on-screen keyboard. You can use these features to test your programs and make sure they will work on other languages of Windows and with the full range of available Unicode characters. You can test with multiple languages by following a few steps:

  1. Enable the system to read and write files in the languages you want to test with.
  2. Enable keyboard layouts for the languages you want to test with.
  3. Change your dialogs to use a new system font, MS Shell Dlg 2.
  4. Enter characters into your app using the new keyboard layouts or the Charmap program.

Note that you must have a Unicode build of your app. If you try this with an ANSI build, you can only enter characters that are in the code page of the language of your OS. If you try entering other characters, they will either show up as question marks, or different letters that are missing diacritics.

Enabling foreign languages

The first thing to do is configure the system to read and write files in other languages. Log in as an administrator and open the Regional Options control panel. At the bottom of the first page, there is a checklist box with a list of languages, as shown here.

 [Regional Options control panel - 17K]

Check all the languages that you want to test with. For this example, check Japanese and Vietnamese, and click OK. Windows will install fonts, IMEs, and other necessary files and then reboot.

Adding foreign-language keyboard layouts

After the reboot, open the Keyboard control panel and click the Input Locales tab. Click the Add button and then pick a language in the Input Locale combo box. For this example, choose Japanese. The IME combo box should show "Japanese Input System (MS-IME 2000)" as shown here:

 [Adding keyboard layouts - 30K]

Click OK. Click Add again and select Vietnamese, then click OK. Your Keyboard property sheet should look like this:

 [All languages added - 28K]

Click OK to save your changes. There should now be a language indicator icon in the tray, which will show the native language of the OS (for example, "EN" if you're using English Windows). Pressing Left Alt+Shift rotates your keyboard language among the languages you set in the Keyboard control panel. You can also left-click the language indicator to get a menu of all the installed languages.

Changing dialog fonts

Now that the system is set up to let you enter foreign-language characters, you need to tweak your dialogs so they can display the characters. Windows 2000 has a new system font name, MS Shell Dlg 2. This is not a real font, but rather a special name the system recognizes. When a dialog is created with this font, the system substitutes a font that is capable of displaying characters in all of the installed languages. (You can read about Windows NT font substitution in MSDN under Platform SDK\Windows Base Services\International Features\National Language Support\About National Language Support\Localization and the Shell Font.) By default this font is Tahoma. Once you set your dialogs to use this font, they will automatically be able to display any Unicode character from any installed language. Note that you'll need to edit your .RC files by hand, since you can't set the font to MS Shell Dlg 2 through the MSVC dialog editor.

Entering foreign-language characters

If you change the keyboard language to Japanese, you'll see the IME in the lower-right corner. Using the IME requires knowledge of Japanese to enter correct syllables (and teaching Japanese is a little beyond the scope of this article), so for the purposes of testing you can use Charmap to enter Japanese characters.

To run Charmap, click Start, point to Programs, point to Accessories, point to System Tools, and click Character Map. Select either the MS Mincho or MS Gothic font, and scroll the character list down until you see the Japanese characters. Double-clicking any character adds it to the edit box at the bottom of the window, and clicking Copy puts all the characters in the edit box onto the Clipboard. Here is what Charmap looks like after double-clicking three characters:

 [Charmap - 27K]

After copying the characters to the Clipboard, you can them paste them into any input field in your program.

Another way to enter characters is by using the on-screen keyboard, a new Accessibility feature in Windows 2000. The on-screen keyboard lets you click buttons with your mouse, instead of hunting for keys on the keyboard. To open the on-screen keyboard, click Start, point to Programs, point to Accessories, point to Accessibility, and click On-Screen Keyboard. The Vietnamese keyboard is shown here:

 [On-screen keyboard - 21K]

Other languages will differ, naturally, in the placement of some letters. For Vietnamese, the top row of keys enters diacritics and accented letters, as well as the two keys between P and backslash. To add a diacritic to a vowel, type the vowel and then the diacritic. For example, to enter the name Nguyen, type "Nguy" as normal letters. To enter the e (which has both a circumflex and a tilde), press the 3 key (for ê) and then press the 7 key to add the tilde.

When you want to use the on-screen keyboard, click in the window that you want to receive the keystrokes, and then click in the on-screen keyboard window. When you click buttons on the keyboard, the keystrokes will be sent to the window with the focus.

You can get the latest updates to this and my other articles at http://home.inreach.com/mdunn/code/

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior) VMware
United States United States
Michael lives in sunny Mountain View, California. He started programming with an Apple //e in 4th grade, graduated from UCLA with a math degree in 1994, and immediately landed a job as a QA engineer at Symantec, working on the Norton AntiVirus team. He pretty much taught himself Windows and MFC programming, and in 1999 he designed and coded a new interface for Norton AntiVirus 2000.
Mike has been a a developer at Napster and at his own lil' startup, Zabersoft, a development company he co-founded with offices in Los Angeles and Odense, Denmark. Mike is now a senior engineer at VMware.

He also enjoys his hobbies of playing pinball, bike riding, photography, and Domion on Friday nights (current favorite combo: Village + double Pirate Ship). He would get his own snooker table too if they weren't so darn big! He is also sad that he's forgotten the languages he's studied: French, Mandarin Chinese, and Japanese.

Mike was a VC MVP from 2005 to 2009.

Comments and Discussions

 
QuestionHow to save and display Greek Characters in text box Pin
srimail0923-Jun-09 19:57
srimail0923-Jun-09 19:57 
GeneralNeed to implement a language Pin
shweta.shrivastava2-Nov-06 21:53
shweta.shrivastava2-Nov-06 21:53 
GeneralRe: Need to implement a language Pin
khmer18-Mar-07 22:19
khmer18-Mar-07 22:19 
QuestionDisplay lang. characters???????????? Pin
Anonymous27-Sep-05 2:19
Anonymous27-Sep-05 2:19 
AnswerRe: Display lang. characters???????????? Pin
Michael Dunn27-Sep-05 5:26
sitebuilderMichael Dunn27-Sep-05 5:26 
GeneralRe: Display lang. characters???????????? Pin
acrao806-Nov-05 19:34
acrao806-Nov-05 19:34 
GeneralRe: Display lang. characters???????????? Pin
Michael Dunn13-Nov-05 12:21
sitebuilderMichael Dunn13-Nov-05 12:21 
GeneralRe: Display lang. characters???????????? Pin
vivian_qjh12-Jan-06 20:21
vivian_qjh12-Jan-06 20:21 
QuestionDisplay language characters?????? Pin
Anonymous27-Sep-05 1:35
Anonymous27-Sep-05 1:35 
GeneralForeign Language support Pin
AlexEvans7-Apr-05 18:13
AlexEvans7-Apr-05 18:13 
Generalxilli I am facing a similar problem Pin
Zephyr_BP27-Dec-04 2:52
Zephyr_BP27-Dec-04 2:52 
Generaljapanese characters fall over Pin
Anonymous16-Oct-03 0:08
Anonymous16-Oct-03 0:08 
GeneralRe: japanese characters fall over Pin
oniak0115-Aug-04 19:40
oniak0115-Aug-04 19:40 
Generalwestern european characters input/output problems on win2k of east_asia version Pin
xili6-Jun-03 5:32
xili6-Jun-03 5:32 
western european characters input/output problems on win2k of east_asia version

background:
the platform is win2k of chinese version.

DWORD lcid3 = GetSystemDefaultLCID(); // ==> 2052
DWORD lcid4 = GetUserDefaultLCID(); // ==> 2052
LANGID langid3 = GetSystemDefaultLangID(); // ==> 2052
LANGID langid4 = GetUserDefaultLangID(); // ==> 2052

problem 1: RichEdit

char buf[20];
SendMessage( Handle_of_RichEdit, EM_GETSELTEXT, 0, (LPARAM) (LPSTR) buf);

the two selected charaters in the RichEdit is "\xF6\xE4"(german characters);
but the content of buf is "\x20\x20\x0".

problem 2: TextOut

char buf[20];
buf[0] = '1';
buf[1] = 224;

LOGFONT lf2;

memset (&lf2,0,sizeof(lf2));
lf2.lfHeight = 36;
lf2.lfWeight = FW_NORMAL;
lf2.lfCharSet = ANSI_CHARSET;
lf2.lfOutPrecision = OUT_DEFAULT_PRECIS;
lf2.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf2.lfQuality = DEFAULT_QUALITY;
lf2.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
strcpy(lf2.lfFaceName,"Arial");

HFONT hf = CreateFontIndirect(&lf2);
HDC hdc = GetDC ( hwnd);

HFONT hold = SelectObject(hdc,hf);

TextOut(hdc, 20, 20, buf, 2 );

the character buf[1] on screen is the \.notdef of the font.


a unwilling resolution:
the problems disapear when I set the system default language
to "western and american" through control panel .

it seems like the win2k treat the character(>127) as
chinese character in stead of western european character,

there must be a way to correct them without modifying the platform system,
anybody help ?


QuestionHow can I creat my own IMEs (input method editors) Pin
Phan Van Long21-Feb-03 5:53
sussPhan Van Long21-Feb-03 5:53 
QuestionResource Files ? Pin
Anonymous14-Nov-02 6:34
Anonymous14-Nov-02 6:34 
GeneralBetter use "MS Shell Dlg" with DS_SHELLFONT Pin
uwph21-Oct-02 23:30
sussuwph21-Oct-02 23:30 
GeneralNice to have. Pin
Martin Marvinski9-Jul-02 9:56
Martin Marvinski9-Jul-02 9:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.