MBCS Support in Visual C++

Unicode TasksMultibyte Character Set (MBCS) Tasks

When run on an MBCS-enabled version of the Windows 95 or Windows NT operating system, the Visual C++ development system, including the integrated source code editor, debugger, and command line tools, is completely MBCS-enabled. Visual C++ will accept double-byte characters wherever it is appropriate to do so. This includes path names and file names in dialog boxes, and text entries in the Visual C++ resource editor (for example, static text in the dialog editor and static text entries in the icon editor). In addition, the preprocessor recognizes some double-byte directives ? for example, file names in #include statements, and as arguments to the code_seg and data_seg pragmas. In the source code editor, double-byte characters in comments and string literals are accepted, although not in C/C++ language elements (such as variable names).

Support for the Input Method Editor (IME)

Applications written for Far East markets that use MBCS (for example, Japan) normally support the Windows IME for entering both single- and double-byte characters. The Visual C++ development environment contains full support for the IME.

Japanese keyboards do not directly support Kanji characters. The IME converts a phonetic string, entered in one of the other Japanese alphabets, Romaji, Katakana, or Hiragana, into its possible Kanji representations. If there is ambiguity, you can select from several alternatives. Once you have selected the intended Kanji character, the IME passes two WM_CHAR messages to the controlling application.

The IME, activated by the ALT+` key combination, appears as a set of buttons (an indicator) and a conversion window. The application positions the window at the text insertion point. The application must handle WM_MOVE and WM_SIZE messages by repositioning the conversion window to conform to the new location or size of the target window.

If you want users of your application to have the ability to enter Kanji characters, the application must handle Windows IME messages. For more information on IME programming, see the Internationalization Handbook for Software Design in the Microsoft Development Library.

Visual C++ Debugger

The Visual C++ debugger provides the ability to set breakpoints on IME messages. In addition, the Memory window can display double-byte characters.

Command-Line Tools

The Visual C++ command-line tools, including the compiler, NMAKE, and the resource compiler (RC.EXE), are MBCS-enabled. You can use the resource compiler’s /c option to change the default code page when compiling your application’s resources.

To change the default locale at source code compile time, use #pragma setlocale.

Graphical Tools

The Visual C++ Windows-based tools, such as Spy++ and the resource editing tools, fully support IME strings.

See Also   MBCS Programming Tips