PreviousInternationalization Support The COBOL Interfacing EnvironmentNext

Chapter 9: National Language Support (NLS) Demonstration

This chapter demonstrates NLS functionality by sorting a list of European place-names that include accented characters.

9.1 Overview

The NLS demonstration sorts the same list using the same code twice. The NLS Compiler directive is set for the first sort; it is set off (NONLS) for the second sort. The results of the two sorts are displayed together so you can compare the different sort sequences. In this demonstration, the list of names is encoded in two standard character sets: ISO 8859-1 and IBM PC. You need a terminal that can display one of these in order to run the demonstration. Providing that you set up the demonstration's copyfile correctly, (see the section Running the Sample Programs) the displayed results should be the same for both ISO 8859-1 and IBM PC character sets.

9.2 Files Required for the Sample Programs

You need the following files to run the NLS sample programs:

nlsdemo.cbl Source for main program and non-NLS subroutine
nlssort.cbl Source for the NLS subroutine
sortsub.cpy Copyfile of code common to both subroutines

Use Infomgr to find these.

9.3 Running the Sample Programs

To run the NLS sample programs.

  1. Choose the character set supported by your terminal display: ISO 8859-1 or IBM PC.

  2. Edit the sortsub.cpy file to remove the comment on the level-78 item for the character set you are using and use comments to disable the line for the other character set. For example, if you are using the IBM PC character set, disable the level-78 item for ISO as follows:
    *78  charset                      value "ISO".
     78  charset                      value "IBMPC". 
  3. Compile the nlsdemo.cbl and nlssort.cbl source files:
    cob nlsdemo.cbl nlssort.cbl
  4. Link the compiled nlsdemo and nlssort files.

  5. Set the LANG environment variable to the appropriate value for the desired locale, that is, language, territory and codepage.

    UNIX:
    On UNIX, to use the ISO 8859-1 codeset for French, enter the command line:

    LANG=fr_FR
    export LANG

    AIX:
    On AIX, to use the IBM PC codeset for French, enter the command line:

    LANG=Fr_FR
    export LANG
  6. Run nlsdemo:
    cobrun nlsdemo

The results of the sorts are displayed on the screen. See the section Typical Results below for a sample of expected output from this sample program. If your results do not match those shown, the UNIX system files defining the collating sequence for that LANG environment variable setting might be non-standard. Your system administrator can modify these so that they give the expected results.

9.4 Typical Results

The table below shows the first 24 lines that are displayed on your screen as a result of sorting European place names containing accented characters. The left-hand column shows typical results for sorting the list without the NLS Compiler directive set (NONLS). The right-hand column shows typical results for sorting the list with the NLS Compiler directive set.

NONLS Compiler Directive NLS Compiler Directive

Aschaffenburg
Bl3vands Huk
Brìzová *
Böda
Chatel-Guyon
Châlons S. Marne
Château Thierry
Châteauneuf en Thîm.
Crèvecoeur le Gd.
Cádiz
Córdoba
Föhr
Göteborg
Hj|rring
La Campiña
Leucate
Lébn
Lörrach
Muhlhausen
Munden
Munnerstadt
Mys` gliborz *
Málaga
Mâcon
Mâcon
Mühldorf
München
Nice
Nievre
Nyköping
Næstrved
Nîmes
Nürnberg
Oddes
Oslo
Perusaic *
Peñaranda
Poznad *
Roma

Äland
Älborg
Aschaffenburg
Blåvands Huk
Böda
Brìzová *
Cádiz
Châlons S. Marne
Château Thierry
Châteauneuf en Thîm.
Chatel-Guyon
Córdoba
Crèvecoeur le Gd.
Èáslav *
Ètaples
Föhr
Göteborg
Hjørring
La Campiña
Lébn
Leucate
Lörrach
Mâcon
Mâcon
Málaga
Mühldorf
Muhlhausen
München
münchen
Munden
Munnerstadt
Mys` gliborz *
Næstrved
Nice
Nievre
Nîmes
Nürnberg
Nyköping
Oddes


Notes:



Copyright © 2000 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousInternationalization Support The COBOL Interfacing EnvironmentNext