Jump to content

WinCompareStrings: Difference between revisions

From EDM2
Created page with "Compares two null-terminated strings defined using the same code page. ==Syntax== WinCompareStrings(hab, idCodepage, idCountryCode, pszString1, pszString2, ulReserved) ==P..."
 
 
Line 45: Line 45:
==Remarks==
==Remarks==
The first code page of either of the two ASCII code pages specified in CONFIG.SYS is used as the system default. The following is the list of valid code pages:
The first code page of either of the two ASCII code pages specified in CONFIG.SYS is used as the system default. The following is the list of valid code pages:
{| class="wikitable"
|+ PC Code Pages
|-
! Country !! Code Page
|-
| Canadian-French || 863
|-
| Desktop Publishing || 1004
|-
| Iceland || 861
|-
| Latin 1 Multilingual || 850
|-
| Latin 2 Multilingual || 852
|-
| Nordic || 865
|-
| Portuguese || 860
|-
| Turkey || 857
|-
| U.S. (IBM PC) || 437
|}


Country
{| class="wikitable"
        Code Page  
|+ EBCDIC Code Pages (Character Set 697)
Canadian-French
|-
        863
! Country !! Code Page
Desktop Publishing
|-
        1004
| Austrian/German || 273
Iceland
|-
        861
| Belgian || 500
Latin 1 Multilingual
|-
        850
| Brazil || 037
Latin 2 Multilingual
|-
        852
| Czechoslovakia || 870
Nordic
|-
        865
| Danish/Norwegian || 277
Portuguese
|-
        860
| Finnish/Swedish || 278
Turkey
|-
        857
| French || 297
U.S. (IBM PC)
|-
        437
| Hungary || 870
|-
| Iceland || 871
|-
| International || 500
|-
| Italian || 280
|-
| Poland || 870
|-
| Portuguese || 037
|-
| Spanish || 284
|-
| Turkey || 1026
|-
| U.K.-English || 285
|-
| U.S.-English || 037
|-
| Yugoslavia || 870
|}


Code page 1004 is compatible with Microsoft** Windows**.
{| class="wikitable"
 
|+ Valid Country Codes
The following EBCDIC code pages, based on character set 697, are also available for output:
|-
 
! Country !! Code
Country
|-
        Code Page
| Arabic || 785
Austrian/German
|-
        273
| Australian || 61
Belgian
|-
        500
| Belgian || 32
Brazil
|-
        037
| Canadian-French || 2
Czechoslovakia
|-
        870
| Danish || 45
Danish/Norwegian
|-
        277
| Finnish || 358
Finnish/Swedish
|-
        278
| French || 33
French
|-
        297
| German || 49
Hungary
|-
        870
| Hebrew || 972
Iceland
|-
        871
| Italian || 39
International
|-
        500
| Japanese || 81
Italian
|-
        280
| Korean || 82
Poland
|-
        870
| Latin-American || 3
Portuguese
|-
        037
| Netherlands || 31
Spanish
|-
        284
| Norwegian || 47
Turkey
|-
        1026
| Portuguese || 351
U.K.-English
|-
        285
| Simpl. Chinese || 86
U.S.-English
|-
        037
| Spanish || 34
Yugoslavia
|-
        870
| Swedish || 46
 
|-
Code pages 274 (Belgian) and 282 (Portuguese) can be used to provide access to old data. The following is the list of valid country codes:
| Swiss || 41
 
|-
 
| Trad. Chinese || 88
Country
|-
        Code
| UK-English || 44
Arabic
|-
        785
| US-English || 1
Australian
|-
        61
| Other country || 0
Belgian
|}
        32
Canadian-French
        2
Danish
        45
Finnish
        358
French
        33
German
        49
Hebrew
        972
Italian
        39
Japanese
        81
Korean
        82
Latin-American
        3
Netherlands
        31
Norwegian
        47
Portuguese
        351
Simpl. Chinese
        86
Spanish
        34
Swedish
        46
Swiss
        41
Trad. Chinese
        88
UK-English
        44
US-English
        1
Other country
        0


==Example Code==
==Example Code==

Latest revision as of 19:16, 14 May 2025

Compares two null-terminated strings defined using the same code page.

Syntax

WinCompareStrings(hab, idCodepage, idCountryCode, pszString1, pszString2, ulReserved)

Parameters

hab (HAB) - input
Anchor-block handle.
idCodepage (ULONG) - input
Code page identity of both strings.
If idCodepage is set to 0, the current code page of the caller is used.
idCountryCode (ULONG) - input
Country code.
If idCountryCode is set to 0, the country information for the default system country code is used.
pszString1 (PSZ) - input
String 1.
pszString2 (PSZ) - input
String 2.
ulReserved (ULONG) - input
Reserved value, should be 0.

Returns

ulResult (ULONG) - returns
Comparison result.
WCS_EQ
Strings are equal
WCS_LT
String 1 is less than string 2
WCS_GT
String 1 is greater than string 2
WCS_ERROR
Error occurred.

Errors

Possible returns from WinGetLastError

PMERR_INVALID_STRING_PARM (0x100B)
The specified string parameter is invalid.

Remarks

The first code page of either of the two ASCII code pages specified in CONFIG.SYS is used as the system default. The following is the list of valid code pages:

PC Code Pages
Country Code Page
Canadian-French 863
Desktop Publishing 1004
Iceland 861
Latin 1 Multilingual 850
Latin 2 Multilingual 852
Nordic 865
Portuguese 860
Turkey 857
U.S. (IBM PC) 437
EBCDIC Code Pages (Character Set 697)
Country Code Page
Austrian/German 273
Belgian 500
Brazil 037
Czechoslovakia 870
Danish/Norwegian 277
Finnish/Swedish 278
French 297
Hungary 870
Iceland 871
International 500
Italian 280
Poland 870
Portuguese 037
Spanish 284
Turkey 1026
U.K.-English 285
U.S.-English 037
Yugoslavia 870
Valid Country Codes
Country Code
Arabic 785
Australian 61
Belgian 32
Canadian-French 2
Danish 45
Finnish 358
French 33
German 49
Hebrew 972
Italian 39
Japanese 81
Korean 82
Latin-American 3
Netherlands 31
Norwegian 47
Portuguese 351
Simpl. Chinese 86
Spanish 34
Swedish 46
Swiss 41
Trad. Chinese 88
UK-English 44
US-English 1
Other country 0

Example Code

This example compares two strings using the same code page: the first string is loaded from a resource DLL, while the second is created by the application.

#define INCL_WINCOUNTRY         /* Window Country Functions     */
#define INCL_WINWINDOWMGR       /* Window Manager Functions     */
#define INCL_DOSMODULEMGR       /* Module Manager Functions     */
#include <os2.h>

ULONG   ulResult;       /* comparison result                    */
HAB     hab;            /* anchor-block handle                  */
ULONG   idCodepage=437; /* Code page identity of both strings   */
ULONG   idCountryCode=1;/* Country code                         */
char    pszString1[10]; /* first string                         */
char    pszString2[10]; /* second string                        */
LONG    lLength;        /* length of string                     */
ULONG   idString = STRING_ID; /* String identifier              */
LONG    lBufferMax = 10;/* Size of buffer                       */
HMODULE hmodDLL;        /* Handle of the module which contains
                           the help table and help subtable
                           resources.                           */
CHAR    LoadError[100]; /* object name buffer for DosLoad       */
ULONG   rc;             /* return code                          */

/* obtain resource handle */
rc = DosLoadModule(LoadError, sizeof(LoadError), "RES.DLL",
                   &hmodDLL);

/* load string from resource */
if (rc == 0)
   lLength = WinLoadString(hab, hmodDLL, idString, lBufferMax,
                            pszString1);

/* compare strings */
if (lLength > 0)
   {
   /* set second string */
   strcpy(pszString2,"Compare");

   ulResult = WinCompareStrings(hab, idCodepage, idCountryCode,
                                pszString1, pszString2, 0);
   }

Definition

#define INCL_WINCOUNTRY /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

HAB      hab;            /*  Anchor-block handle. */
ULONG    idCodepage;     /*  Code page identity of both strings. */
ULONG    idCountryCode;  /*  Country code. */
PSZ      pszString1;     /*  String 1. */
PSZ      pszString2;     /*  String 2. */
ULONG    ulReserved;     /*  Reserved value, should be 0. */
ULONG    ulResult;       /*  Comparison result. */

ulResult = WinCompareStrings(hab, idCodepage,
             idCountryCode, pszString1, pszString2,
             ulReserved);


Related Functions

  • WinLoadString
  • WinNextChar
  • WinPrevChar
  • WinSubstituteStrings
  • WinUpper
  • WinUpperChar