The API program LNCCVTWCS converts the contain of a character variable from or to the Unicode Windows character set.
Syntax
DCL |
VAR(&HANDLE) TYPE(*CHAR) LEN(50) |
DCL |
VAR(&DIRECTION) TYPE(*CHAR) LEN(10) |
DCL |
VAR(&WCS_VAR) TYPE(*CHAR) LEN(...) |
DCL |
VAR(&WCS_SIZE) TYPE(*DEC) LEN(5) |
DCL |
VAR(&CHAR_VAR) TYPE(*CHAR) LEN(...) |
DCL |
VAR(&CHAR_SIZE) TYPE(*DEC) LEN(5) |
DCL |
VAR(&CCSID) TYPE(*DEC) LEN(5) |
DCL |
VAR(&RES_SIZE) TYPE(*DEC) LEN(5) |
DCL |
VAR(&OPTION) TYPE(*CHAR) LEN(...) |
|
|
CALL |
PGM(LNCCVTWCS) PARM(&HANDLE &DIRECTION + &WCS_VAR &WCS_SIZE + &CHAR_VAR &CHAR_SIZE + &CCSID &RES_SIZE &OPTION) |
Parameters
Parameters |
|
&DIRECTION |
This
parameter contains : *FROM to convert the value of parameter &CHAR_VAR from the Windows Unicode character set, to another character set.
|
&WCS_VAR |
Input or Output : The string value, coded with the Windows Unicode character set.. When &DIRECTION=’*TO’, &WCS_VAR contains the result of the conversion. When &DIRECTION=’*FROM’, &WCS_VAR contains the string to convert.
|
&WCS_SIZE |
Size in bytes of parameter &WCS_VAR. When
&DIRECTION=’*TO’, &WCS_SIZE is the size allocated
to variable &WCS_VAR.
|
&CHAR_VAR |
Input or Output : The character value, coded with the character set specified by parameter &CCSID. When &DIRECTION=’*TO’, &CHAR_VAR is the string to convert. When &DIRECTION=’*FROM’, &CHAR_VAR will be the result of the conversion.
|
&CHAR_SIZE |
Size in bytes of parameter &CHAR_VAR. When
&DIRECTION=’*TO’, &CHAR_SIZE is the number of
characters to convert in &WCS_VAR. |
&CCSID |
Character set for the value of &CHAR_VAR. The Unicode value of &WCS_VAR will be converted to or from the character set specified in &CCSID. If &CCSID is 0, the current job CCSID is used.
|
&RES_SIZE |
Output. Size in bytes of the resulting string in &WCS_VAR or &CHAR_VAR.
|
&OPTION |
Possible values are : NZSTR : (Non zero string) When
&DIRECTION=’*TO’, the Unicode result will not be
terminated by a null character. When
&DIRECTION=’*FROM’, if the Unicode string was
terminated by a null character, it will be removed in the converted string
|
|
|
The
Unicode character set handled by LNCCVTWCS
is not the UCS2 character on OS/400.
When used with XLCELLS and WBOOKMARK in LAUNCHER Office, this API program allows to read and write text in Excel and Word, using foreign character sets (Chinese, Korean, …), and use DBCS character sets on AS/400.
Examples
|
/* Read value
of cell B2 in Unicode Windows */ |
CHGVAR |
VAR(&CMD) VALUE('XLCELLS') |
CHGVAR |
VAR(&PARM1) VALUE('Ref=”$B$2”;GetText=True;Unicode=True') |
CHGVAR |
VAR(&PARM2) VALUE(' ') |
CALL |
PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 + &PARM2 &RESULT) |
|
/* &RESULT
contains value of B2 in Unicode */ |
|
/* Convert &RESULT to Chinese CCSID */ |
CHGVAR |
VAR(&WCS_LEN) VALUE(-1) |
CHGVAR |
VAR(&CCSID) VALUE(835) |
CHGVAR |
VAR(&CHINA_SIZE) VALUE(1000) |
CALL |
PGM(LNCCVTWCS) PARM(&HANDLE '*FROM ' &RESULT &WCS_LEN + &CHINA &CHINA_SIZE &CCSID &RES_SIZE) |