WinNextChar
Appearance
This function moves to the next character in a string.
Syntax
WinNextChar(hab, ulCodepage, ulCountry, pszCurrentChar)
Parameters
- hab (HAB) - Input
- Anchor-block handle.
- ulCodepage (ULONG) - Input
- Code page.
- If a non-existent code page is specified for ulCodepage, the code page specified by the queue associated with the calling thread is used.
- ulCountry (ULONG) - Input
- Reserved value, must be 0.
- pszCurrentChar (PSZ) - Input
- Current character in a null-terminated string.
Returns
- pszNextChar (PSZ) - returns
- Pointer to the next character in the null-terminated string.
- When the end of the string is reached, a pointer to the null-terminating character is returned.
Remarks
This function handles DBCS strings.
The following is the list of valid code pages:
- 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
Code page 1004 is compatible with Microsoft Windows.
The following EBCDIC code pages, based on character set 697, are also available for output:
- 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
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:
- 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
Errors
Possible returns from WinGetLastError:
- PMERR_INV_CODEPAGE (0x2052) - An invalid code-page was specified. This error can be obtained if using double-byte character set only.
- PMERR_INVALID_STRING_PARM (0x100B) - The specified string parameter is invalid.
Example Code
This example uses WinNextChar to traverse a string until a specified character is found, while maintaining an index to point to the character's position.
#define INCL_WINCOUNTRY /* Window Country Functions */ #include <os2.H> #include <string.h> // Required for strcpy 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 *pszNextChar; /* Next character */ char *pszCurrentChar; /* Current character */ ULONG ulIndex; /* Array index */ /* Set initial values */ strcpy(pszString1,"Compare"); pszCurrentChar = pszString1; ulIndex = 0; do { pszNextChar = WinNextChar(hab, 437, 0, pszCurrentChar); // Assuming 'hab' is initialized (was habMain in original) /* The next line is necessary to get the next char */ pszCurrentChar = pszNextChar; /* Set emergency escape route, just in case */ ulIndex = ulIndex + 1; if (ulIndex >10) break; } while (*pszNextChar != (char)NULL);