PreviousInternationalization Support The COBOL Interfacing EnvironmentNext"

Chapter 8: National Language Support (NLS) Demonstration

16-bit and UNIX:
The National Language Support (NLS) facility is available on the 16-bit COBOL system and most UNIX COBOL systems.

This chapter demonstrates NLS functionality by sorting a list of European place-names that include accented characters. 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.

8.1 Overview

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 Demonstration) the displayed results should be the same for both ISO 8859-1 and IBM PC character sets.

8.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

These are located in the directory $COBDIR/demo/nls on UNIX and in the directory c:\cobol\demo on DOS, Windows and OS/2.

8.3 Running the Sample Programs

This section describes how to run the NLS sample programs on DOS, Windows and OS/2 environments and on UNIX environments.

  1. Determine the appropriate extended character set for your environment:
  1. Edit the sortsub.cpy file to uncomment the level-78 item for the character set you are using and comment out the line for the other character set. For example if you are using the IBM PC character set, comment out the level-78 item for ISO as follows:
    *78  charset                      value "ISO".
     78  charset                      value "IBMPC".

  2. Compile the nlsdemo.cbl and nlssort.cbl source files.

    DOS and OS/2:
    On DOS and OS/2, enter the command lines:

    cobol nlsdemo.cbl;
    cobol nlssort.cbl;

    Windows:
    On Windows, enter the command lines:

    cobolw nlsdemo.cbl;
    cobolw nlssort.cbl;

    You can omit the link step by compiling the sample programs to .gnt files, and running the .gnt files; enter the following command lines:

    cobol nlsdemo omf(gnt);
    cobol nlssort omf(gnt);

    UNIX:
    On UNIX, enter the command line:

    cob nlsdemo.cbl nlssort.cbl

  3. Link the compiled nlsdemo and nlssort files to either the shared run-time system (coblib) or the static linked run-time system (lcobol).

    DOS:
    To link nlsdemo.obj and nlssort.obj with the shared run-time system on DOS enter the following command lines:

    cob -x:r nlsdemo asciisrt
    cob -x:r nlssort

    To link nlsdemo.obj and nlssort.obj with the static run-time system on DOS, substitute -x:lr for -x:r in the command lines above.

    Windows:
    To link nlsdemo.obj and nlssort.obj with the shared run-time system on Windows, enter the following command lines:

    cob -x:w nlsdemo asciisrt
    cob -x:w nlssort

    To link nlsdemo.obj and nlssort.obj with the static linked run-time system on Windows, enter the following command lines:

    cob -x:lw nlsdemo asciisrt
    cob -x:lw nlssort

    OS/2:
    To link nlsdemo.obj and nlssort.obj with the shared run-time system on OS/2, enter the following command lines:

    cob -x:p nlsdemo asciisrt
    cob -x:p nlssort

    To link nlsdemo.obj and nlssort.obj with the static run-time system on OS/2, substitute -x:lp for -x:p in the command lines above.

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

    DOS, Windows and OS/2:
    On DOS, Windows and OS/2, to specify a language of French, using the default operating system values for territory and codepage, enter the command line:

    set coblang=7

    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

  5. Run nlsdemo.

    DOS, Windows and OS/2:
    On DOS, Windows and OS/2, enter the command line:

    nlsdemo

    or if you have compiled the programs to .gnt files, enter the command line:

    run nlsdemo

    UNIX:
    On UNIX, enter the command line:

    cobrun nlsdemo

The results of the sorts are displayed on the screen. The left-hand side shows the sort done with the NONLS Compiler directive set; that is, the ASCII collating sequence. The right-hand side shows the sort done with the NLS Compiler directive set; that is, the NLS collating sequence. See the section Typical Results for a sample of expected output from this sample program.

UNIX:
If your results do not match those shown in the section Typical Results, 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.

8.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
Blåvands 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


Note: This table shows example results of running the NLS sample programs. The exact sort sequence depends on factors such as the collating sequence and codepage of the locale specified in the LANG environment variable. For best results, specify a locale (in the LANG environment variable) that uses all the accented characters in the collating sequence. For example on DOS or OS/2, accented characters are displayed more accurately using CODEPAGE 850 (the international codepage) than using CODEPAGE 437 (the default codepage). See your operating system documentation for details on determining this.



Copyright © 1999 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"