MS-DOS 6.22 Code Page Switching Explained
MS-DOS 6.22 handles international character conversion and display through its National Language Support (NLS) subsystem. When a user switches code pages, the operating system does not translate the underlying byte values stored in files or memory; instead, it dynamically reconfigures the hardware glyph rendering tables, keyboard scan-code translation buffers, and system sorting and case-mapping tables. This architecture allows the 8-bit operating system to interpret and display extended ASCII characters (values 128 through 255) according to regional standards using resident drivers and precompiled Code Page Information (.CPI) files.
The Core Components of NLS
Character conversion in MS-DOS relies on several coordinated drivers
and utilities configured in CONFIG.SYS and
AUTOEXEC.BAT:
NLSFUNC.EXE: The National Language Support Function driver is loaded as a Terminate-and-Stay-Resident (TSR) program. It provides the system-level application programming interface (via Interrupt 21h, Function 66h) that permits code page querying and global switching.COUNTRY.SYS: A binary lookup table that provides localized formatting rules for dates, times, currency, sorting sequences (collating tables), and uppercase/lowercase conversion tables.DISPLAY.SYSandPRINTER.SYS: Low-level device drivers that intercept text output and manage the font generator hardware of the display adapter and attached parallel printers..CPIFiles: Binary packages containing font bitmap definitions for display hardware (e.g.,EGA.CPI) and character matrices for dot-matrix or daisy-wheel printers.KEYB.COM: The keyboard driver that intercepts Interrupt 09h to map physical keyboard scan codes into specific extended ASCII character codes.
The Code Page Switching Process
When a user or batch process triggers a code page switch—typically
via the CHCP [code] command or through
MODE CON: CODEPAGE SELECT=[code]—the operating system
executes a distinct hardware and software reconfiguration sequence.
- Command Dispatch: The
CHCPcommand issues a call to Interrupt 21h, Function 66h (Set Code Page). - Device Preparation and Verification:
NLSFUNCverifies that the target code page is valid and has been prepared in memory for the active devices. Devices prepare their buffers using previously executedMODE CON CODEPAGE PREPAREcommands, which extract the relevant character bitmaps from the appropriate.CPIfile. - Video Font Reloading:
DISPLAY.SYSinterfaces with the video subsystem. For EGA and VGA adapters, it utilizes Video BIOS Interrupt 10h (specifically service 11h) or direct register manipulation to overwrite the Character Generator RAM (Font Bank). It loads the 8x8, 8x14, or 8x16 pixel bitmaps corresponding to the selected code page into character generator memory. As a result, the existing byte values in text-mode video memory (Buffer B800h for color text) immediately render with the newly loaded glyph shapes. - Keyboard Mapping Adjustment: The
KEYB.COMTSR intercepts the code page switch signal. It swaps its active translation table in memory, altering how raw key scan codes are translated into 8-bit character codes. If a character does not exist in the newly selected code page, the driver generates an alert beep or returns null. - Case and Collating Updates: MS-DOS updates its
internal pointers to point to the case-mapping table and collating
sequence table associated with the new code page from
COUNTRY.SYS. This modifies how internal functions (such as uppercase conversion via Interrupt 21h, Function 65h) handle byte values above 127 during file access and sorting commands.
In-Memory Behavior and Limitations
MS-DOS 6.22 does not modify existing data streams during a code page
switch. Because MS-DOS text files and video displays are streams of raw
8-bit bytes without embedded metadata, changing from Code Page 437
(Standard US) to Code Page 850 (Multilingual Latin I) leaves a byte
value of 0x82 unchanged in memory. Under Code Page 437,
0x82 renders as an "é", whereas other values (such as
box-drawing characters) might morph into accented letters under Code
Page 850. The operating system alters only the visual presentation and
system collation rules, relying entirely on the user or application to
match the displayed code page with the encoding of the target file.