Jump to content

WinCpTranslateString

From EDM2

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

Syntax

WinCpTranslateString(hab, idCpSource, pszSource, idCpDest, cbLenDest, pszDest)

Parameters

hab (HAB) - input
Anchor-block handle.
idCpSource (ULONG) - input
Source-string code page.
pszSource (PSZ) - input
String to be translated.
This is a null-terminated string.
idCpDest (ULONG) - input
Code page of the resultant string.
cbLenDest (ULONG) - input
Maximum length of output string.
An error is raised if this is not large enough to contain the translated string.
pszDest (PSZ) - output
The translated string.
This is a null-terminated string.

Returns

rc (BOOL) - returns
Success indicator.
TRUE - Successful completion
FALSE - Error occurred.

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.
PMERR_PARAMETER_OUT_OF_RANGE (0x1003) :The value of a parameter was not within the defined valid range for that parameter.

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:

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

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

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

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

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

Example Code

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

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

HAB     hab;            /* anchor-block handle                  */
ULONG   idCpSource=437; /* Code page of source character (US)   */
ULONG   idCpDest=850;   /* Code page of dest. character (multi) */
char    pszSource[10];  /* source string                        */
char    pszDest[10];    /* destination string                   */
ULONG   cbLenDest = 9L; /* max length of destination string     */
BOOL    fSuccess;

strcpy(pszSource,"TRANSLATE");
fSuccess = WinCpTranslateString(hab, idCpSource, pszSource,
                                idCpDest, cbLenDest, pszDest);

Related Functions

  • WinCpTranslateChar
  • WinQueryCp
  • WinQueryCpList
  • WinSetCp