Kbase 5993: Using Extended Alphabet support: -xc in 6.2D and above
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
Using Extended Alphabet support: -xc in 6.2D and above
901228-swe01
INTRODUCTION:
=============
This Product Services Technical Support Knowledgebase entry describes
the considerations you have to deal with when you develop and run
applications that use PROGRESS extended support.
WHY YOU NEED TO DO THIS:
========================
In order to use the extended alphabet supported in PROGRESS you must
take certain actions. The actions are different for different OS and
different languages, and includes defining the collating sequence (if
different from standard) and the mapping of characters to and from the
application. There are also some programming considerations.
PROCEDURAL APPROACH:
===================
The Extended Alphabet
---------------------
ASCII codes over 127 are used to store national characters and other
special characters in PROGRESS. This is called the extended alphabet
and coincides with the IBM code page 850. The extended alphabet can
be used on all platforms (even on 7-bit systems). It also makes case
conversions of national characters possible.
Collating Sequence
------------------
Different languages require different rules for string comparisons.
To define the collating sequence for a database, that is, how
characters are sorted, you use the PROUTIL command as the first thing
after you create the database from empty. The syntax is:
PROUTIL database-name -C LANGUAGE language (UNIX, DOS, OS/2)
PROGRESS/UTILITIES=LANGUAGE_language database-name (VMS)
PROGRESS Utilities
Database Name database-name
Utility Name -C utility-name
language language (BTOS)
PROGRESS will sort records correctly within indexes for that
database. This requires that the national characters can be typed in
and sent to the application. On DOS and OS/2 this is no problem
because the ASCII code for a national character sent from the keyboard
always corresponds to the PROGRESS representation of that national
character. So, for DOS and OS/2 the PROUTIL command is all we have to
do.
Character Mapping
-----------------
On the other platforms, you have to define a mapping for some of the
ASCII codes sent from the keyboard to national characters, especially
on 7-bit systems where the terminal can't send ASCII codes over 127.
For example, on UNIX and in Sweden, the ASCII code 123 (decimal) is
used for the national character 'a' which has ASCII code 132 in the
extended alphabet. Therefore we must have a mapping of the code 123 to
132. This mapping is defined in the protermcap file. To activate the
mapping,the TERM variable must end with '/swe' (in Sweden), i.e.,
TERM=vt220/swe. The mapping goes in the other direction too, that is,
when a character field is displayed any national characters are mapped
back to the 'original' values. So, in the above case, the character
132 is mapped back to 123 before display.
There are some 8-bit UNIX systems, but unfortunately, in general the
ASCII codes for national character do not match the PROGRESS extended
alphabet codes. So, we have to use character mappings for those
systems as well.
In the standard protermcap file, mappings for German (/ger), Danish
(/den) and Swedish (/swe) are already defined. Other mappings can be
entered into the protermcap file manually.
Programming Considerations
--------------------------
When a national character has to be used in a program, refer to it
either by its octal value preceded with a tilde (~204 for example), or
use the ;- operator to tell the compiler to exchange it to the mapping
of the subsequent character. For example, the following 'for each'
statement scans through all customers whose name begins with the
national (Swedish) character '8'.
for each customer where name begins ";8":
it will also find the customer who's name begins '8' (caps of 8).
WARNING! The ;-operator is not portable to DOS! That is, the state-
ment above will not work in DOS, it will rather look for customers
whose name begins with ";". Replace ";8" with "~224" to make it
portable (but less readable).
Dictionary Considerations
-------------------------
Running with the character mapping activated, i.e. with the TERM
variable set to .../swe (or dan or ger), causes problems when an
include file is referenced in a validation expression for a field or
file in the dictionary. The problem is easily solved by using the
alternative representation ;( for the usual character for the start of
an include file reference ({). In the same way PROGRESS treats ;) as
the end of an include file reference. See table 2-10 in chapter 2.5.1
in The Programming Handbook (v6) for other alternative representations
of special characters. So, substitute the line
{ custval.v }
with
;( vustval.v ;)
and the problems disappear.
In this case the ;-operator is portable to DOS!
Other Considerations
--------------------
It is very important that the TERM variable always ends with /xxx (xxx
= dan, ger or swe usually). If someone runs without /xxx the mapping
will not be in effect. The data entered during that session will at
first sight appear to be correct but they will not be sorted correctly
within indexes. They display correctly on the screen but they are not
stored correctly in the database. To ensure that this does not happen,
you can test the TERM variable in the start program with the 'TERMINAL'
function in PROGRESS. For example:
IF NOT TERMINAL MATCHES "*/swe" THEN DO:
TERMINAL = TERMINAL + "/swe".
MESSAGE "You had a wrong TERM variable setting.".
MESSAGE "It is now fixed.".
END.
The TERM variable setting could cause problems when you make an OS
escape and start a terminal dependent program (vi for example). Use
the TERMINAL statement to temporarily change the TERM variable.
For string comparisons and sorting done in execution, PROGRESS uses the
collating sequence for the first connected database. Indexes are
organized according to the collating sequence defined for the database
the index belongs to, no matter what the collating sequence is for the
sessions.
Use the -xc startup option (version 6 and later) to explicitly set the
collating sequence for string comparisons and sorting for the sessions.
Avoid passing constant text strings with national chars as include
file arguments. If you do, remember to escape them with the proper
number (3,7,15 ...) of tilde characters. It is better to either
substitute the character with the octal ASCII equivalent for the
national character (preceded by a tilde), which require that the
mapping is active when the program is running, or store the string in a
variable and pass the variable name instead.
ONLINE PROCEDURES OR UTILITIES:
===============================
None
REFERENCE TO WRITTEN DOCUMENTATION:
===================================
Version 5 Documentation:
------------------------
Programming Handbook, Chapter 14.4 and 13.5 (Extended Alphabet).
System Administration, Chapter 2.9.9 (PROUTIL command).
Version 6 Documentation:
------------------------
System Administration II, Chapter 3.2.74 (-xc startup option).
Programming Handbook, Chapter 2.5 (Extended Alphabet).
System Administration II, Chapter 3.2.13 (PROUTIL command).
Documentation Bulletin VI, Start Up Options
Progress Software Technical Support Note # 5993