Jump to content

WinCpTranslateChar

From EDM2
Revision as of 20:39, 21 November 2023 by Ak120 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function translates a character from one code page to another.

Syntax

WinCpTranslateChar(hab, idCpSource, ucSource, idCpDest)

Parameters

hab (HAB) - input
Anchor-block handle.
idCpSource (ULONG) - input
Source-character code page.
ucSource (UCHAR) - input
Character to be translated.
idCpDest (ULONG) - input
Code page of the resultant character.

Returns

ucDest (UCHAR) - returns
If nonzero, the translated or substitution (0xFF) character.

Errors

Possible returns from WinGetLastError

PMERR_INVALID_STRING_PARM (0x100B) The specified string parameter is invalid.
PMERR_INVALID_SRC_CODEPAGE (0x101D) The source code page parameter is invalid.
PMERR_INVALID_DST_CODEPAGE (0x101E) The destination code page parameter is invalid.

Remarks

Successful invocation of this function indicates that either (1) the character was directly mapped into the destination code page or, (2) the substitution character (0xFF) was returned.

The following is the list of valid 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

Code page 1004 is compatible with Microsoft** Windows**.

The following EBCDIC code pages, based on character set 697, are also available for output:

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

Code pages 274 (Belgian) and 282 (Portuguese) can be used to provide access to old data.

Example Code

This example translates a character from US code page 437 to multilingual code page 850.

#define INCL_WINCOUNTRY         /* Window Country Functions     */
#include <os2.h>

HAB     hab;            /* anchor-block handle                  */
UCHAR   ucDest;         /* translated character                 */
UCHAR   ucSource = 'A'; /* source character                     */
ULONG   idCpSource=437; /* Code page of source character (US)   */
ULONG   idCpDest=850;   /* Code page of dest. character (multi) */

ucDest = WinCpTranslateChar(hab, idCpSource, ucSource, idCpDest);

Related Functions

  • WinCpTranslateString
  • WinQueryCp
  • WinQueryCpList
  • WinSetCp