TrnsDt
This function converts the SBCS and DBCS strings from one code page to another. Personal Communications and Communications Server provide TrnsDt in the TRNSDT.DLL file. TransDt is available only on a DBCS session.
Syntax
TrnsDt (PASSSTRUCT *passparm);
This function converts the SBCS and DBCS strings from one code page to another. In the following table, a check mark (✓) indicates that Personal Communications supports the conversion between the pair of code pages; a hyphen (-) indicates that neither program supports that conversion.
| Code Pages | 1386 | 836 | 837 | 1388 |
|---|---|---|---|---|
| 1386 | - | ✓ | ✓ | ✓ |
| 836 | ✓ | - | - | - |
| 837 | ✓ | - | - | - |
| 1388 | ✓ | - | - | - |
| Code Pages | 932/943 | 930 | 931 | 939 | 290 | 037 | 1027 | 1390 | 1399 |
|---|---|---|---|---|---|---|---|---|---|
| 932/943 | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| 930 | ✓ | - | - | - | - | - | - | - | - |
| 931 | ✓ | - | - | - | - | - | - | - | - |
| 939 | ✓ | - | - | - | - | - | - | - | - |
| 290 | ✓ | - | - | - | - | - | - | - | - |
| 037 | ✓ | - | - | - | - | - | - | - | - |
| 1027 | ✓ | - | - | - | - | - | - | - | - |
| 1390 | ✓ | - | - | - | - | - | - | - | - |
| 1399 | ✓ | - | - | - | - | - | - | - | - |
| Code Pages | 949 | 833 | 834 | 933 | 1363 | 1364 |
|---|---|---|---|---|---|---|
| 949 | - | ✓ | ✓ | ✓ | - | - |
| 833 | ✓ | - | - | - | ✓ | - |
| 834 | ✓ | - | - | - | - | - |
| 933 | ✓ | - | - | - | - | - |
| 1363 | - | ✓ | - | - | - | ✓ |
| 1364 | - | - | - | - | ✓ | - |
| Code Pages | 950 | 037 | 835 | 937 | 1370 | 1371 | 1159 |
|---|---|---|---|---|---|---|---|
| 950 | - | ✓ | ✓ | ✓ | - | - | - |
| 037 | ✓ | - | - | - | - | - | - |
| 835 | ✓ | - | - | - | - | - | - |
| 937 | ✓ | - | - | - | - | - | - |
| 1370 | - | - | - | - | - | ✓ | ✓ |
| 1371 | - | - | - | - | ✓ | - | - |
| 1159 | - | - | - | - | ✓ | - | - |
Use the header file TRNSDT.H to compile, and use the TRNSDT.LIB file from either program's LIB subdirectory to link.
- WORD parm_length
- Length of this structure (input)
- WORD exit_code
- Exit code (output)
- 0000H
- Normal end.
- 0001H
- Not supported conversion specified.
- 000CH
- Exit_code field is not initialized to
0. - 0080H
- The last character is the left half of a DCBS. Null character is filled instead.
- WORD in_length
- Length of the source buffer (input)
- LPBYTE in_addr
- Source buffer address (input)
- WORD out_length
- Length of target buffer (input)
If the specified length is too small to return all of the converted data, the required length is returned.
- LPBYTE out_addr
- Target address buffer (input)
- WORD trns_id
- Reserved to zero (input)
- WORD in_page
- Source code page (input)
- WORD out_page
- Target code page (input)
- WORD option
- Option (input/output)
- Input
- Input options are as follows;
- Bits 15–9
- Reserved to zero
- Bit 8
- Target string has SO/SI
- Bits 7–3
- Reserved to zero
- Bit 2
- Use non-editable SBCS table
- Bit 1
- Source string starts with DBCS
- Bit 0
- Source string has SO/SI
- Output
- Output options are as follows:
- 4
- End at DBCS
- 0
- End at non-DBCS
- Bit 8 and Bit 0 should be set as follows:
- Conversion from PC to host Bit 8=1
- Conversion from PC to host Bit 0=0
- Conversion from host to PC Bit 8=0
- Conversion from host to PC Bit 0=1
- Use SYSCTBL.EXE to specify the name of the customized
table that TrnsDt uses. To convert an SBCS string, TrnsDt uses the customized table with the Option parameter bit 2 set to
FALSE. TrnsDt uses the default table if bit 2 is set but the name of the table is not specified. To convert a DBCS string when the name of the table is specified using SYSCTBL.EXE, TrnsDt always uses the customized table. In this case, the Option parameter for bit 2 is not used. - Generally, TrnsDt requires that the host data include SO/SI control characters as a pair. However, to convert a part of a mixed data string, the data must start with a double-byte character without an SO control character. In this case, data does not identify the double-byte character. Bit 1 is useful in such a case. When you set bit 1 to 1, TrnsDt processes the start of the buffer as a double-byte character or SO control character.
- 0
- NO_ERROR
- 2
- ERROR_FILE_NOT_FOUND
TrnsDt cannot find the table used for converting the specified
code. - 87
- ERROR_INVALID_PARAMETER
Parameter is not valid.
- 111
- ERROR_BUFFER_OVERFLOW
The target buffer is too small.
- 150
- ERROR_MEMORY_ALLOCATE
Memory allocation error.
Even a small buffer can handle a large data conversion successfully by using the exit code and option parameters of TrnsDt. First, start TrnsDt using a small source buffer and a double- or triple-sized destination buffer (for cases from PC to host), and see how the conversion ends, based on the exit code you receive. Then proceed accordingly.
For example, when the conversion divides a double-byte character into two parts, or it ends incompletely between SO and SI control characters, define the buffer pointer and its position, then perform the next call.
0x4040 to PC
code.
#include "trnsdt.h"
PASSSTRUCT passparm;
char bufs[20], buft[20];
int rc;
//Setup the string to be translated
bufs[0] = 0x0e;
bufs[1] = 0x40;
bufs[2] = 0x40;
bufs[3] = 0x4f;
//Setup the parameter
passaparm.parm_length = 24;
passparm.exit_code = 0;
passaparm.in_length = 4;
passaparm.in_addr = Created by ActiveSystems. 02/11/97. Entity not defined[0];
passaparm.out_length = 20;
passaparm.out_addr = Created by ActiveSystems. 02/11/97. Entity not defined[0];
passaparm.trns_id = 0;
passaparm.in_page = 930;
passaparm.out_page = 932;
passaparm.option = 1;
//Translate the string via TrnsDt
if (rc = TrnsDt(&passaparm))
printf("Error Return Code = %d\n\r", rc);
printf("Exit Code = %d\n\r", passaparm.exit_code);
exit(0);
else
.....