How to Change the Localization of FreeDOS

Set the keyboard layout and codepage according to your needs

If your native language is not English, or if you just need to work with files containing different characters other than English, you may struggle with how to display or write these properly. The purpose of this guide is to show how to work with codepages and keyboard layouts, so the settings finally respect your national environment.

Codepages and Devices

To do the settings properly, we need to understand the concept of devices and codepages in FreeDOS. Codepages in FreeDOS are 8-bit, so there are 256 characters at maximum defined for one codepage for the purpose of use for a specific language or group of languages.

English is the default option for FreeDOS, and the corresponding codepage is 437. (All codepages are defined by their number.) If we decide to use Greek, we switch to 737, and for Central European languages it is 852. These numbers respect the codepages defined by IBM for its PC DOS.

Every time you set the codepage in FreeDOS, you do it for a specific device. These devices are named, the most common example is CON for console you directly interact with while typing, or COM as a device representing the serial port. You need to be aware that there may be different codepages set for different devices.

(You may also notice there may be multiple codepages and keyboard layouts existing for a single language, this is mostly due to the historical reasons, or other specifics.)

Regional settings

Apart from the codepage and devices, there are also national settings. There is COUNTRY.SYS you might load in FDCONFIG.SYS config file, and specify the country code to get e.g., correct date, time, and number format. If we use Czech Republic as an example, we may end up with following line:

COUNTRY=42,852,C:\FreeDOS\BIN\COUNTRY.SYS

The configuration is pretty staightforward, as 42 is the country code. It is possible to find other country codes via HELP, and then checking the COUNTRY.SYS item, as well as the codepages these are typically bound to.

Codepage and Keyboard Setting

To set the codepage and keyboard layout, you need to use multiple commands. Via DISPLAY you set the assumed graphics card, and its default hardware codepage. Using MODE you first load the new codepage you are about to use, which is defined in the format if CPI file, and then finally set it - note: it is still valid for one specific device entered there.

Last step is to set the keyboard layout itself via KEYB command. You can pass three arguments there: layout name defining the physical identifier of the layout, codepage, and lastly, the file containing the layout definition. The last one may be omitted, if the layout is located in the default file, which is KEYBOARD.SYS.

Let's jump into an example:

DISPLAY CON=(EGA,437,1) MODE CON CODEPAGE PREPARE=((852) C:\FREEDOS\CPI\EGA.CPX) MODE CON CODEPAGE SELECT=852 KEYB CZ,852

The example from above expects the graphic hardware to be an EGA card with 437 default codepage. We set the Latin 2 codepage 852 for Central European group of languages (e.g., Czech, Polish). The definition of this codepage is located in the EGA.CPX file, and the keyboard layout is CZ. There was no need to specify the layout file as it is already covered by the default one.

Let's experiment with something slightly different:

DISPLAY CON=(EGA,437,1) MODE CON CODEPAGE PREPARE=((848) C:\FREEDOS\CPI\EGA4.CPX) MODE CON CODEPAGE SELECT=848 KEYB UA,848,C:\FREEDOS\BIN\KEYBRD3.SYS

Second example is for Ukrainian national environment setting. The principle is the same as in the previous case, just notice the different codepage 848 containing Cyrillic letters specific to the Ukrainian alphabet. The CPI file also differs, as well as the file with keyboard layout definition.

There is another thing you may be surprised by the moment you execute all the commands from above and nothing happens: when you type any character, there is still just the standard Latin character, not Cyrillic, printed out. You did nothing wrong! Ukrainian keyboard is an example of, so called, dual script keyboard. You switch between the Latin and national keyboard via a key combination. Here it is [ALT]+[LEFTSHIFT] and [ALT]+[RIGHTSHIFT].

Tips and Tricks

You may wonder where all the CPX file names, layout names, and files with keyboard definition came from? These are listed in LAYOUTS.TXT available in FreeDOS docs for KEYB utility. (See C:\FreeDOS\DOC\KEYB\LAYOUTS). You can find these also using HELP utility, and then checking KPDOS.

Another thing is the length of the commands used. Is there a way to make it shorter? Yes, there is! For example the CODEPAGE keyword in the MODE command can be shortened into CP, and PREPARE to PREP, as well as SELECT to SEL.

Is there a way how to change the codepages for all the devices available at once? Yes, you can do it via the CHCP utility also available in FreeDOS.