We show a typical combination of the optional parameters of TrnsDt in
Combination of the TrnsDt parameters for Japanese for your convenience.
Example of TrnsDt usage from 32-bit code (source: MISCWIN.C)
#pragma pack(2) /* parameter for TrnsDt will be */
/* packed along 2-byte boundary */
struct TrnsDtParm /* Parameters for TrnsDt */
{
USHORT Length; /* Length of parameters */
USHORT exit; /* Exit code */
USHORT SourceLen; /* Length of a source string */
char * _Seg16 pSource; /* (far) Address of a source string */
USHORT TargetLen; /* Length of a target string */
char * _Seg16 pTarget; /* (far) Address of a target string */
USHORT id; /* Translation id */
USHORT SourceCP; /* Source code page */
USHORT TargetCP; /* Target code page */
USHORT Options; /* Translation options */
};
#pragma pack()
extern USHORT _Far16 _Pascal TrnsDt(struct TrnsDtParm *);
#pragma seg16(Tparm)
struct TrnsDtParm Tparm;
MRESULT EXPENTRY cpConvDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
...
Tparm.Length = sizeof(Tparm);
Tparm.exit = 0;
Tparm.SourceLen = strlen(szBufIn);
Tparm.pSource = szBufIn;
Tparm.TargetLen = sizeof(szBufOut);
Tparm.pTarget = szBufOut;
Tparm.id = 0;
Tparm.SourceCP = *pPcCodePage;
Tparm.TargetCP = atoi(szCurrentHost);
if ((*pHost).CPflag == combined)
/*---- Options for a combined code page ------------*/
/* Bit 8 (on) : SO/SI in a target string */
/* Bit 2 (on) : Use the IBM-defined table */
/* Bit 0 (off): No SO/SI in a source string */
/*--------------------------------------------------*/
Tparm.Options = 0x0104;
else
/*---- Options for a SBCS or a DBCS code page ------*/
/* Bit 8 (off): No SO/SI in a target string */
/* Bit 2 (on) : Use the IBM-defined table */
/* Bit 0 (off): No SO/SI in a source string */
/*--------------------------------------------------*/
Tparm.Options = 0x0004;
TrnsDt(&Tparm);
...
Options of TrnsDt at Example of TrnsDt usage from 32-bit code (source:
MISCWIN.C)
Bit 15-9
┌──────────┬────────┬────────┬────────┬──────────┬───────────────┬───────────────┬───────────────┬───────────────┐│From/To │String │From CP │To CP │parameter │Bit 8 │Bit 2 │Bit 1 │Bit 0 │ │ │type │ │ │ │ │ │ │ │ ├──────────┼────────┼────────┼────────┼──────────┼───────────────┼───────────────┼───────────────┼───────────────┤ │ASCII to │Mix to │942 or │1027 or │0x0004 │Off (No SO/SI │On (Use │Off (The first │Off (No SO/SI │ │EBCDIC │SBCS │932 │290 │ │at target) │IBM-supplied │character is │at source ) │ │ │ │ │ │ │ │table) │SBCS.) │ │ ├──────────┼────────┼────────┼────────┼──────────┼───────────────┼───────────────┼───────────────┼───────────────┤ │ASCII to │Mix to │942 or │930 or │0x0104 │On (SO/SI at │On (Use │Off (The first │Off (No SO/SI │ │EBCDIC │Mix │932 │939 │ │target) │IBM-supplied │character is │at source ) │ │ │ │ │ │ │ │table) │SBCS.) │ │ ├──────────┼────────┼────────┼────────┼──────────┼───────────────┼───────────────┼───────────────┼───────────────┤ │ASCII to │Mix to │942 or │300 │0x0004 │Off (No SO/SI │On (Use │Off (The first │Off (No SO/SI │ │EBCDIC │DBCS │932 │ │ │at target) │IBM-supplied │character is │at source ) │ │ │ │ │ │ │ │table) │SBCS.) │ │ ├──────────┼────────┼────────┼────────┼──────────┼───────────────┼───────────────┼───────────────┼───────────────┤ │EBCDIC to │SBCS to │1027 or │932 or │0x0004 │Off (No SO/SI │On (Use │Off (The first │Off (No SO/SI │ │ASCII │Mix │290 │942 │ │at target) │IBM-supplied │character is │at source ) │ │ │ │ │ │ │ │table) │SBCS.) │ │ ├──────────┼────────┼────────┼────────┼──────────┼───────────────┼───────────────┼───────────────┼───────────────┤ │EBCDIC to │Mix to │930 or │932 or │0x0005 │Off (No SO/SI │On (Use │Off (The first │On (SO/SI at │ │ASCII │Mix │939 │942 │ │at target) │IBM-supplied │character is │source ) │ │ │ │ │ │ │ │table) │SBCS.) │ │ ├──────────┼────────┼────────┼────────┼──────────┼───────────────┼───────────────┼───────────────┼───────────────┤ │EBCDIC to │DBCS to │300 │932 or │0x0006 │Off (No SO/SI │On (Use │On (The first │Off (No SO/SI │ │ASCII │Mix │ │942 │ │at target) │IBM-supplied │character is │at source ) │ │ │ │ │ │ │ │table) │DBCS.) │ │ ├──────────┼────────┼────────┼────────┼──────────┼───────────────┼───────────────┼───────────────┼───────────────┤ │ASCII │Mix to │942 or │1027 or │0x0005 │Off (No SO/SI │On (Use │Off (The first │On (SO/SI at │ │(with │SBCS │932 │290 │ │at target) │IBM-supplied │character is │source ) │ │pseudo │ │ │ │ │ │table) │SBCS.) │ │ │SO/SI) to │ │ │ │ │ │ │ │ │ │EBCDIC │ │ │ │ │ │ │ │ │ ├──────────┼────────┼────────┼────────┼──────────┼───────────────┼───────────────┼───────────────┼───────────────┤ │ASCII │Mix to │942 or │930 or │0x0105 │On (SO/SI at │On (Use │Off (The first │On (SO/SI at │ │(with │Mix │932 │939 │ │target) │IBM-supplied │character is │source ) │ │pseudo │ │ │ │ │ │table) │SBCS.) │ │ │SO/SI) to │ │ │ │ │ │ │ │ │ │EBCDIC │ │ │ │ │ │ │ │ │ ├──────────┼────────┼────────┼────────┼──────────┼───────────────┼───────────────┼───────────────┼───────────────┤ │ASCII │Mix to │942 or │300 │0x0005 │Off (No SO/SI │On (Use │Off (The first │On (SO/SI at │ │(with │DBCS │932 │ │ │at target) │IBM-supplied │character is │source ) │ │pseudo │ │ │ │ │ │table) │SBCS.) │ │ │SO/SI) to │ │ │ │ │ │ │ │ │ │EBCDIC │ │ │ │ │ │ │ │ │ ├──────────┼────────┼────────┼────────┼──────────┼───────────────┼───────────────┼───────────────┼───────────────┤ │EBCDIC to │SBCS to │1027 or │932 or │0x0004 │Off (No SO/SI │On (Use │Off (The first │Off (No SO/SI │ │ASCII │Mix │290 │942 │ │at target) │IBM-supplied │character is │at source ) │ │(with │ │ │ │ │ │table) │SBCS.) │ │ │pseudo │ │ │ │ │ │ │ │ │ │SO/SI) │ │ │ │ │ │ │ │ │ ├──────────┼────────┼────────┼────────┼──────────┼───────────────┼───────────────┼───────────────┼───────────────┤ │EBCDIC to │Mix to │930 or │932 or │0x0105 │On (SO/SI at │On (Use │Off (The first │On (SO/SI at │ │ASCII │Mix │939 │942 │ │target) │IBM-supplied │character is │source ) │ │(with │ │ │ │ │ │table) │SBCS.) │ │ │pseudo │ │ │ │ │ │ │ │ │ │SO/SI) │ │ │ │ │ │ │ │ │ ├──────────┼────────┼────────┼────────┼──────────┼───────────────┼───────────────┼───────────────┼───────────────┤ │EBCDIC to │DBCS to │300 │932 or │0x0006 │Off (No SO/SI │On (Use │On (The first │Off (No SO/SI │ │ASCII │Mix │ │942 │ │at target) │IBM-supplied │character is │at source ) │ │(with │ │ │ │ │ │table) │DBCS.) │ │ │pseudo │ │ │ │ │ │ │ │ │ │SO/SI) │ │ │ │ │ │ │ │ │ └──────────┴────────┴────────┴────────┴──────────┴───────────────┴───────────────┴───────────────┴───────────────┘