WinCpTranslateChar: Difference between revisions
Appearance
Created page with "This function translates a character from one code page to another. ==Syntax== WinCpTranslateChar(hab, idCpSource, ucSource, idCpDest); ==Parameters== ; hab (HAB) - input ..." |
mNo edit summary |
||
Line 1: | Line 1: | ||
This function translates a character from one code page to another. | This function translates a character from one code page to another. | ||
==Syntax== | ==Syntax== | ||
WinCpTranslateChar(hab, idCpSource, ucSource, idCpDest) | WinCpTranslateChar(hab, idCpSource, ucSource, idCpDest) | ||
==Parameters== | ==Parameters== | ||
; hab (HAB) - input | ;hab (HAB) - input: Anchor-block handle. | ||
: Anchor-block handle. | ;idCpSource (ULONG) - input:Source-character code page. | ||
;ucSource (UCHAR) - input:Character to be translated. | |||
;idCpSource (ULONG) - input | ;idCpDest (ULONG) - input:Code page of the resultant character. | ||
:Source-character code page. | |||
;ucSource (UCHAR) - input | |||
:Character to be translated. | |||
;idCpDest (ULONG) - input | |||
:Code page of the resultant character. | |||
==Returns== | ==Returns== | ||
; ucDest (UCHAR) - returns | ;ucDest (UCHAR) - returns: If nonzero, the translated or substitution (0xFF) character. | ||
: If nonzero, the translated or substitution (0xFF) character. | |||
==Errors== | ==Errors== | ||
Possible returns from WinGetLastError | 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== | ==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: | The following is the list of valid code pages: | ||
{| | |||
!Country||Code Page | |||
|- | |||
Canadian-French | |Canadian-French||863 | ||
|- | |||
Desktop Publishing | |Desktop Publishing||1004 | ||
|- | |||
Iceland | |Iceland||861 | ||
|- | |||
Latin 1 Multilingual | |Latin 1 Multilingual||850 | ||
|- | |||
Latin 2 Multilingual | |Latin 2 Multilingual||852 | ||
|- | |||
Nordic | |Nordic||865 | ||
|- | |||
Portuguese | |Portuguese||860 | ||
|- | |||
Turkey | |Turkey||857 | ||
|- | |||
U.S. (IBM PC) | |U.S. (IBM PC)||437 | ||
|} | |||
Code page 1004 is compatible with Microsoft** Windows**. | Code page 1004 is compatible with Microsoft** Windows**. | ||
The following EBCDIC code pages, based on character set 697, are also available for output: | The following EBCDIC code pages, based on character set 697, are also available for output: | ||
{| | |||
!Country||Code Page | |||
|- | |||
Austrian/German | |Austrian/German||273 | ||
|- | |||
Belgian | |Belgian||500 | ||
|- | |||
Brazil | |Brazil||037 | ||
|- | |||
Czechoslovakia | |Czechoslovakia||870 | ||
|- | |||
Danish/Norwegian | |Danish/Norwegian||277 | ||
|- | |||
Finnish/Swedish | |Finnish/Swedish||278 | ||
|- | |||
French | |French||297 | ||
|- | |||
Hungary | |Hungary||870 | ||
|- | |||
Iceland | |Iceland||871 | ||
|- | |||
International | |International||500 | ||
|- | |||
Italian | |Italian||280 | ||
|- | |||
Poland | |Poland||870 | ||
|- | |||
Portuguese | |Portuguese||037 | ||
|- | |||
Spanish | |Spanish||284 | ||
|- | |||
Turkey | |Turkey||1026 | ||
|- | |||
U.K.-English | |U.K.-English||285 | ||
|- | |||
U.S.-English | |U.S.-English||037 | ||
|- | |||
Yugoslavia | |Yugoslavia||870 | ||
|} | |||
Code pages 274 (Belgian) and 282 (Portuguese) can be used to provide access to old data. | |||
Code pages 274 (Belgian) and 282 (Portuguese) can be used to provide access to old data. | |||
==Example Code== | ==Example Code== | ||
This example translates a character from US code page 437 to multilingual code page 850. | This example translates a character from US code page 437 to multilingual code page 850. | ||
<pre> | <pre> | ||
#define INCL_WINCOUNTRY /* Window Country Functions */ | #define INCL_WINCOUNTRY /* Window Country Functions */ | ||
Line 114: | Line 101: | ||
ucDest = WinCpTranslateChar(hab, idCpSource, ucSource, idCpDest); | ucDest = WinCpTranslateChar(hab, idCpSource, ucSource, idCpDest); | ||
</pre> | </pre> | ||
Latest revision as of 20:39, 21 November 2023
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