home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
nlsnps.zip
/
nls.doc
< prev
next >
Wrap
Text File
|
1996-09-05
|
7KB
|
207 lines
OS/2 National Language Support functions Manual
[Abstract]
This package is intended for easy use of OS/2's National Language
Support (NLS) functions. All the functions defined in this package
can be used only for C++, not C. If you are a skilled C programmer,
I think you can convert them into C programs.
With these NLS functions, you can create international programs
easier, especially DBCS language programs. DBCS means Double Byte
Code System, and one DBCS character consists of 2 bytes. In DBCS,
some of the characters consist only of one byte like English, and the
rest consists of two bytes. I am a Japanese, and the Japanese language
is one of the DBCS languages.
This package is totally free. You can use, modify, and distribute it
freely without any permission. I have renounced my copyright on it.
[File Description]
This package contains these files. Some of these filenames are
invalid on a FAT drive, and UNZIP will truncate them into 8.3
filenames. For example, "nlsInitialize.cpp" will be renamed to
"NLSINITI.CPP" on a FAT drive.
1. nls.h
2. nlsCompare.cpp
3. nlsData.cpp
4. nlsIncludeDBCS.cpp
5. nlsInitialize.cpp
6. nlsSearch.cpp
7. nlsUpperString.cpp
"nls.h" is the header file necessary to use the NLS functions.
OS/2's basic header file "os2.h" must be included before "nls.h"
is included, because "nls.h" contains OS/2's type definitions
such as PUCHAR, UINT, etc.
Other C++ source files must be compiled yourself. I use Borland C++
for OS/2, and I have not tested other compilers.
To see the source files properly on the command line window,
the window width of at least 100 columns is necessary.
[Function Description]
1. void nlsInitialize()
This function initializes the character information necessary for
all the other NLS functions in this package. It is recommended to call
this function once at the head of main(). Call this function again if
the codepage of the process is changed.
2. PUCHAR nlsSearch(PUCHAR psz, UINT ui)
This function searches the specified character in the string. It is
quite similar to the strchr function in C, but nlsSearch is aware of
DBCS character sets. The first argument psz is the pointer to the
string, and the second argument ui is the character to be searched.
If the character is found, a pointer to it is returned. Otherwise
NULL is returned.
If you want to search a DBCS character, give it as a 16-bit number.
Put the head byte in the highter 8 bits, and the tail byte in the lower
8 bits. Note that Intel's microprocessors are little-endian
so reading 16 bits at the address of the DBCS string will give the
combination of the head byte in the lower 8 bits and the tail byte in
the highter 8 bits.
You can also pass the head byte of a DBCS character as the second
argument.
3. PUCHAR nlsSearch(PUCHAR pb, UINT ui, UINT cbLength)
Similar to the nlsSearch function with 2 arguments shown above,
but with 3 arguments this function works for a memory area rather than
a string. It doesn't care for the null at the end of the string.
The third argument cbLength determines the maximum length of bytes to
be searched in, like the memchr function in C.
4. PUCHAR nlsSearchCollate(PUCHAR psz, UINT ui)
Similar to the nlsSearch function, but this function ignores case
like the strichr function in C. This function uses the "collate value"
which is returned by the DosQueryCollate API, so accented characters
are also treated the same as an ordinary character.
5. PUCHAR nlsSearchCollate(PUCHAR pb, UINT ui, UINT cbLength)
With 3 arguments this function works for a memory area.
6. PUCHAR nlsSearchLast(PUCHAR psz, UINT ui)
This function works like nlsSearch, but returns a pointer to the last
occurrence of the specified character. It is similar to the strrchr
function in C. NULL will be returned if the string doesn't contain the
specified character.
7. PUCHAR nlsSearchLast(PUCHAR pb, UINT ui, UINT cbLength)
With 3 arguments this function works for a memory area.
8. PUCHAR nlsSearchCollateLast(PUCHAR psz, UINT ui)
The nlsSearchLast function with the collate value.
9. PUCHAR nlsSearchCollateLast(PUCHAR pb, UINT ui, UINT cbLength)
The nlsSearchLast function with the collate value.
10. BOOL nlsIncludeDBCS(PUCHAR psz)
It returns TRUE if the string contains a DBCS character, FALSE if
not.
11. int nlsCountChar(PUCHAR psz)
This function counts the number of characters in the string.
Remember that one DBCS character consists of two bytes. The strlen
function in C returns the length of the string in bytes, not in
characters.
12. int nlsCompare(PUCHAR psz1, PUCHAR psz2)
This function compares two strings given as psz1 and psz2, and
returns zero if the two strings are the same, a negative value if psz1
is smaller in the alphabetical order, or a positive value if psz1 is
bigger. All comparison is made according to the collate values.
13. PUCHAR nlsUpperString(PUCHAR psz)
It converts the string into upper case. The string will be
overwritten. This function returns the first argument.
14. PUCHAR nlsLowerString(PUCHAR psz)
It converts the string into lower case. The string will be
overwritten. This function returns the first argument.
15. UCHAR nlsIsDBCS(UCHAR uc)
It returns TRUE if the character is the head byte of a DBCS
character. In that case, the next byte must be the tail byte.
The tail byte can take any value practically, so you cannot determine
the tail byte of the DBCS character without knowing where the head
byte is. Be sure that nlsIsDBCS returns TRUE for some tail bytes,
because they share the same codes even with the head bytes. You must
start from the head of the string to handle DBCS characters properly.
16. UCHAR nlsUpper(UCHAR uc)
It gives the upper case of the character. Do not use for the DBCS
tail bytes.
17. UCHAR nlsLower(UCHAR uc)
It gives the lower case of the character. Do not use for the DBCS
tail bytes.
18. UCHAR nlsCollate(UCHAR uc)
It returns the collate value, which is useful for comparison. Do not
use for the DBCS tail bytes.
19. PUCHAR nlsNext(PUCHAR psz)
This function returns psz + 1 if *psz is an ordinary character,
or psz + 2 if *psz is the head byte of a DBCS character.
(the tail byte is skipped)
[Other]
I am not very good at using English, so if there is something
unclear, please send me an email. I will gladly reply to you to
support your programming of international softwares.
Thank you very much for downloading my software.
TAKASUGI Shinji (surname first - Japanese way)
member of Team OS/2 Japan
nps1970@ibm.net, jbd03575@niftyserve.or.jp