2
Licensed Materials - Property of IBM
3
DB2 Storage Engine Enablement
4
Copyright IBM Corporation 2007,2008
7
Redistribution and use in source and binary forms, with or without modification,
8
are permitted provided that the following conditions are met:
9
(a) Redistributions of source code must retain this list of conditions, the
10
copyright notice in section {d} below, and the disclaimer following this
12
(b) Redistributions in binary form must reproduce this list of conditions, the
13
copyright notice in section (d) below, and the disclaimer following this
14
list of conditions, in the documentation and/or other materials provided
15
with the distribution.
16
(c) The name of IBM may not be used to endorse or promote products derived from
17
this software without specific prior written permission.
18
(d) The text of the required copyright notice is:
19
Licensed Materials - Property of IBM
20
DB2 Storage Engine Enablement
21
Copyright IBM Corporation 2007,2008
24
THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
25
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
27
SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
29
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
39
@brief A direct map optimization of iconv and related functions
40
This was show to significantly reduce character conversion cost
41
for short strings when compared to calling iconv system code.
52
#include <as400_protos.h>
54
#include "db2i_myconv.h"
55
#include "db2i_global.h"
57
int32_t myconvDebug=0;
59
static char szGetTimeString[20];
60
static char * GetTimeString(time_t now)
65
tm = (struct tm *) localtime(&now);
66
sprintf(szGetTimeString, "%04d/%02d/%02d %02d:%02d:%02d",
67
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
68
tm->tm_hour, tm->tm_min, tm->tm_sec);
70
return szGetTimeString;
73
static MEM_ROOT dmapMemRoot;
77
init_alloc_root(&dmapMemRoot, 0x200, 0);
82
free_root(&dmapMemRoot,0);
88
#define STDOUT_WITH_TIME -1 /* to stdout with time */
89
#define STDERR_WITH_TIME -2 /* to stderr with time */
90
#define STDOUT_WO_TIME 1 /* : to stdout */
91
#define STDERR_WO_TIME 2 /* : to stderr */
94
static void MyPrintf(long type,
106
fprintf(fd, "%s ", GetTimeString(now));
109
vfprintf(fd, fmt, ap);
117
#define MAX_CONVERTER 128
119
mycstoccsid(const char* pname)
121
if (strcmp(pname, "UTF-16")==0)
123
else if (strcmp(pname, "big5")==0)
126
return cstoccsid(pname);
128
#define cstoccsid mycstoccsid
130
static struct __myconv_rec myconv_rec [MAX_CONVERTER];
131
static struct __dmap_rec dmap_rec [MAX_CONVERTER];
133
static int dmap_open(const char * to,
137
if (myconvIsSBCS(from) && myconvIsSBCS(to)) {
138
dmap_rec[idx].codingSchema = DMAP_S2S;
139
if ((dmap_rec[idx].dmapS2S = (uchar *) alloc_root(&dmapMemRoot, 0x100)) == NULL) {
141
MyPrintf(STDERR_WITH_TIME,
142
"dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
143
to, from, idx, DMAP_S2S, errno, __FILE__,__LINE__);
147
memset(dmap_rec[idx].dmapS2S, 0x00, 0x100);
148
myconv_rec[idx].allocatedSize=0x100;
154
size_t inBytesLeft=0x100;
155
size_t outBytesLeft=0x100;
157
char * inBuf=dmapSrc;
158
char * outBuf=(char *) dmap_rec[idx].dmapS2S;
160
if ((cd = iconv_open(to, from)) == (iconv_t) -1) {
162
MyPrintf(STDERR_WITH_TIME,
163
"dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
164
to, from, idx, errno, __FILE__,__LINE__);
170
for (i = 0; i < inBytesLeft; ++i)
174
if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
177
MyPrintf(STDERR_WITH_TIME,
178
"dmap_open(%s,%s,%d), CS=%d: iconv() returns %d, errno = %d in %s at %d\n",
179
to, from, idx, DMAP_S2S, len, errno, __FILE__,__LINE__);
180
MyPrintf(STDERR_WITH_TIME,
181
"inBytesLeft = %d, inBuf - dmapSrc = %d\n", inBytesLeft, inBuf-dmapSrc);
182
MyPrintf(STDERR_WITH_TIME,
183
"outBytesLeft = %d, outBuf - dmapS2S = %d\n", outBytesLeft, outBuf-(char *) dmap_rec[idx].dmapS2S);
185
if ((inBytesLeft == 86 || inBytesLeft == 64 || inBytesLeft == 1) &&
186
memcmp(from, "IBM-1256", 9) == 0 &&
187
memcmp(to, "IBM-420", 8) == 0) {
188
/* Known problem for IBM-1256_IBM-420 */
195
} else if ((inBytesLeft == 173 || inBytesLeft == 172 ||
196
inBytesLeft == 74 || inBytesLeft == 73 ||
197
inBytesLeft == 52 || inBytesLeft == 50 ||
198
inBytesLeft == 31 || inBytesLeft == 20 ||
200
memcmp(to, "IBM-1256", 9) == 0 &&
201
memcmp(from, "IBM-420", 8) == 0) {
202
/* Known problem for IBM-420_IBM-1256 */
209
} else if ((128 >= inBytesLeft) &&
210
memcmp(to, "IBM-037", 8) == 0 &&
211
memcmp(from, "IBM-367", 8) == 0) {
212
/* Known problem for IBM-367_IBM-037 */
219
} else if (((1 <= inBytesLeft && inBytesLeft <= 4) || (97 <= inBytesLeft && inBytesLeft <= 128)) &&
220
memcmp(to, "IBM-838", 8) == 0 &&
221
memcmp(from, "TIS-620", 8) == 0) {
222
/* Known problem for TIS-620_IBM-838 */
233
/* Tolerant to undefined conversions for any converter */
242
} while (inBytesLeft > 0);
245
myconv_rec[idx].subS=0x1A;
246
else if (myconvIsASCII(to))
247
myconv_rec[idx].subS=0x7F;
248
else if (myconvIsEBCDIC(to))
249
myconv_rec[idx].subS=0x3F;
251
if (myconvIsISO(from))
252
myconv_rec[idx].srcSubS=0x1A;
253
else if (myconvIsASCII(from))
254
myconv_rec[idx].srcSubS=0x7F;
255
else if (myconvIsEBCDIC(from))
256
myconv_rec[idx].srcSubS=0x3F;
260
} else if (((myconvIsSBCS(from) && myconvIsUnicode2(to)) && (dmap_rec[idx].codingSchema = DMAP_S2U)) ||
261
((myconvIsSBCS(from) && myconvIsUTF8(to)) && (dmap_rec[idx].codingSchema = DMAP_S28))) {
264
/* single byte mapping */
265
if ((dmap_rec[idx].dmapD12U = (UniChar *) alloc_root(&dmapMemRoot, 0x100 * 2)) == NULL) {
267
MyPrintf(STDERR_WITH_TIME,
268
"dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
269
to, from, idx, DMAP_S2U, errno, __FILE__,__LINE__);
273
memset(dmap_rec[idx].dmapD12U, 0x00, 0x100 * 2);
274
myconv_rec[idx].allocatedSize=0x100 * 2;
287
#ifdef support_surrogate
288
if ((cd = iconv_open("UTF-16", from)) == (iconv_t) -1) {
290
if ((cd = iconv_open("UCS-2", from)) == (iconv_t) -1) {
293
MyPrintf(STDERR_WITH_TIME,
294
"dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
295
to, from, idx, errno, __FILE__,__LINE__);
300
for (i = 0; i < 0x100; ++i) {
304
outBuf=(char *) &(dmap_rec[idx].dmapD12U[i]);
306
if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
307
if ((errno == EILSEQ || errno == EINVAL) &&
314
MyPrintf(STDERR_WITH_TIME,
315
"dmap_open(%s,%s,%d) failed to initialize with iconv(cd,%02x,%d,%02x%02x,%d), errno = %d in %s at %d\n",
316
to, from, idx, dmapSrc[0], 1,
317
(&dmap_rec[idx].dmapD12U[i])[0],(&dmap_rec[idx].dmapD12U[i])[1], 2,
318
errno, __FILE__,__LINE__);
319
MyPrintf(STDERR_WITH_TIME,
320
"inBytesLeft=%d, outBytesLeft=%d, %02x%02x\n",
321
inBytesLeft, outBytesLeft,
322
(&dmap_rec[idx].dmapD12U[i])[0],(&dmap_rec[idx].dmapD12U[i])[1]);
328
dmap_rec[idx].dmapD12U[i]=0x0000;
330
if (dmap_rec[idx].dmapE02U[i] == 0x001A && /* pick the first one */
331
myconv_rec[idx].srcSubS == 0x00) {
332
myconv_rec[idx].srcSubS=i;
337
myconv_rec[idx].subS=0x1A;
338
myconv_rec[idx].subD=0xFFFD;
341
} else if (((myconvIsUCS2(from) && myconvIsSBCS(to)) && (dmap_rec[idx].codingSchema = DMAP_U2S)) ||
342
((myconvIsUTF16(from) && myconvIsSBCS(to)) && (dmap_rec[idx].codingSchema = DMAP_T2S)) ||
343
((myconvIsUTF8(from) && myconvIsSBCS(to)) && (dmap_rec[idx].codingSchema = DMAP_82S))) {
344
/* UTF-16 -> SBCS, the direct map a bit of waste of space,
345
* binary search may be reasonable alternative
347
if ((dmap_rec[idx].dmapU2S = (uchar *) alloc_root(&dmapMemRoot, 0x10000 * 2)) == NULL) {
349
MyPrintf(STDERR_WITH_TIME,
350
"dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
351
to, from, idx, DMAP_U2S, errno, __FILE__,__LINE__);
355
memset(dmap_rec[idx].dmapU2S, 0x00, 0x10000);
356
myconv_rec[idx].allocatedSize=(0x10000 * 2);
362
#ifdef support_surrogate
363
if ((cd = iconv_open(to, "UTF-16")) == (iconv_t) -1) {
365
if ((cd = iconv_open(to, "UCS-2")) == (iconv_t) -1) {
368
MyPrintf(STDERR_WITH_TIME,
369
"dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
370
to, from, idx, errno, __FILE__,__LINE__);
375
for (i = 0; i < 0x100; ++i) {
376
UniChar dmapSrc[0x100];
378
for (j = 0; j < 0x100; ++j) {
379
dmapSrc[j]=i * 0x100 + j;
381
char * inBuf=(char *) dmapSrc;
382
char * outBuf=(char *) &(dmap_rec[idx].dmapU2S[i*0x100]);
383
size_t inBytesLeft=sizeof(dmapSrc);
384
size_t outBytesLeft=0x100;
387
if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
388
if (inBytesLeft == 0 && outBytesLeft == 0) { /* a number of substitution returns */
393
MyPrintf(STDERR_WITH_TIME,
394
"dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
395
from, to, idx, errno, __FILE__,__LINE__);
396
MyPrintf(STDERR_WITH_TIME,
397
"iconv() retuns %d, errno=%d, InBytesLeft=%d, OutBytesLeft=%d\n",
398
len, errno, inBytesLeft, outBytesLeft, __FILE__,__LINE__);
407
myconv_rec[idx].subS = dmap_rec[idx].dmapU2S[0x1A];
408
myconv_rec[idx].subD = dmap_rec[idx].dmapU2S[0xFFFD];
409
myconv_rec[idx].srcSubS = 0x1A;
410
myconv_rec[idx].srcSubD = 0xFFFD;
415
} else if (((myconvIsDBCS(from) && myconvIsUnicode2(to)) && (dmap_rec[idx].codingSchema = DMAP_D2U)) ||
416
((myconvIsDBCS(from) && myconvIsUTF8(to)) && (dmap_rec[idx].codingSchema = DMAP_D28))) {
418
/* single byte mapping */
419
if ((dmap_rec[idx].dmapD12U = (UniChar *) alloc_root(&dmapMemRoot, 0x100 * 2)) == NULL) {
421
MyPrintf(STDERR_WITH_TIME,
422
"dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
423
to, from, idx, DMAP_D2U, errno, __FILE__,__LINE__);
427
memset(dmap_rec[idx].dmapD12U, 0x00, 0x100 * 2);
429
/* double byte mapping, assume 7 bit ASCII is not use as the first byte of DBCS. */
430
if ((dmap_rec[idx].dmapD22U = (UniChar *) alloc_root(&dmapMemRoot, 0x8000 * 2)) == NULL) {
432
MyPrintf(STDERR_WITH_TIME,
433
"dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
434
to, from, idx, DMAP_D2U, errno, __FILE__,__LINE__);
438
memset(dmap_rec[idx].dmapD22U, 0x00, 0x8000 * 2);
440
myconv_rec[idx].allocatedSize=(0x100 + 0x8000) * 2;
454
#ifdef support_surrogate
455
if ((cd = iconv_open("UTF-16", from)) == (iconv_t) -1) {
457
if ((cd = iconv_open("UCS-2", from)) == (iconv_t) -1) {
460
MyPrintf(STDERR_WITH_TIME,
461
"dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
462
to, from, idx, errno, __FILE__,__LINE__);
467
for (i = 0; i < 0x100; ++i) {
471
outBuf=(char *) (&dmap_rec[idx].dmapD12U[i]);
473
if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
474
if ((errno == EILSEQ || errno == EINVAL) &&
481
MyPrintf(STDERR_WITH_TIME,
482
"dmap_open(%s,%s,%d) failed to initialize with iconv(cd,%02x,%d,%02x%02x,%d), errno = %d in %s at %d\n",
483
to, from, idx, dmapSrc[0], 1,
484
(&dmap_rec[idx].dmapD12U[i])[0],(&dmap_rec[idx].dmapD12U[i])[1], 2,
485
errno, __FILE__,__LINE__);
486
MyPrintf(STDERR_WITH_TIME,
487
"inBytesLeft=%d, outBytesLeft=%d, %02x%02x\n",
488
inBytesLeft, outBytesLeft,
489
(&dmap_rec[idx].dmapD12U[i])[0],(&dmap_rec[idx].dmapD12U[i])[1]);
495
dmap_rec[idx].dmapD12U[i]=0x0000;
497
if (dmap_rec[idx].dmapD12U[i] == 0x001A && /* pick the first one */
498
myconv_rec[idx].srcSubS == 0x00) {
499
myconv_rec[idx].srcSubS=i;
504
for (i = 0x80; i < 0x100; ++i) {
506
if (dmap_rec[idx].dmapD12U[i] != 0x0000)
508
for (j = 0x01; j < 0x100; ++j) {
517
outBuf=(char *) &(dmap_rec[idx].dmapD22U[offset]);
519
if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
520
if (inBytesLeft == 2 && outBytesLeft == 2 && (errno == EILSEQ || errno == EINVAL)) {
521
; /* invalid DBCS character, dmapDD2U[offset] remains 0x0000 */
525
MyPrintf(STDERR_WITH_TIME,
526
"dmap_open(%s,%s,%d) failed to initialize with iconv(cd,%p,2,%p,2), errno = %d in %s at %d\n",
528
dmapSrc, &(dmap_rec[idx].dmapD22U[offset]),
529
errno, __FILE__,__LINE__);
530
MyPrintf(STDERR_WO_TIME,
531
"iconv(cd,0x%02x%02x,2,0x%04x,2) returns %d, inBytesLeft=%d, outBytesLeft=%d\n",
532
dmapSrc[0], dmapSrc[1],
533
dmap_rec[idx].dmapD22U[offset],
534
len, inBytesLeft, outBytesLeft);
543
MyPrintf(STDERR_WITH_TIME,
544
"dmap_open(%s,%s,%d) failed to initialize with iconv(), rc=%d, errno=%d in %s at %d\n",
545
to, from, idx, len, errno, __FILE__,__LINE__);
546
MyPrintf(STDERR_WITH_TIME,
547
"%04X: src=%04X%04X, inBuf=0x%02X%02X, inBytesLeft=%d, outBuf=%02X%02X%02X, outBytesLeft=%d\n",
548
i, dmapSrc[0], dmapSrc[1], inBuf[0], inBuf[1],
549
inBytesLeft, outBuf[-2], outBuf[-1], outBuf[0], outBytesLeft);
550
MyPrintf(STDERR_WITH_TIME,
551
"&dmapSrc=%p, inBuf=%p, %p, outBuf=%p\n",
552
dmapSrc, inBuf, dmap_rec[idx].dmapU2M3 + (i - 0x80) * 2, outBuf);
557
if (dmap_rec[idx].dmapD12U[i] == 0xFFFD) { /* pick the last one */
558
myconv_rec[idx].srcSubD=i* 0x100 + j;
564
myconv_rec[idx].subS=0x1A;
565
myconv_rec[idx].subD=0xFFFD;
566
myconv_rec[idx].srcSubD=0xFCFC;
569
} else if (((myconvIsUCS2(from) && myconvIsDBCS(to)) && (dmap_rec[idx].codingSchema = DMAP_U2D)) ||
570
((myconvIsUTF16(from) && myconvIsDBCS(to)) && (dmap_rec[idx].codingSchema = DMAP_T2D)) ||
571
((myconvIsUTF8(from) && myconvIsDBCS(to)) && (dmap_rec[idx].codingSchema = DMAP_82D))) {
572
/* UTF-16 -> DBCS single/double byte */
573
/* A single table will cover all characters, assuming no second byte is 0x00. */
574
if ((dmap_rec[idx].dmapU2D = (uchar *) alloc_root(&dmapMemRoot, 0x10000 * 2)) == NULL) {
576
MyPrintf(STDERR_WITH_TIME,
577
"dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
578
to, from, idx, DMAP_U2D, errno, __FILE__,__LINE__);
583
memset(dmap_rec[idx].dmapU2D, 0x00, 0x10000 * 2);
584
myconv_rec[idx].allocatedSize=(0x10000 * 2);
596
#ifdef support_surrogate
597
if ((cd = iconv_open(to, "UTF-16")) == (iconv_t) -1) {
599
if ((cd = iconv_open(to, "UCS-2")) == (iconv_t) -1) {
602
MyPrintf(STDERR_WITH_TIME,
603
"dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
604
to, from, idx, errno, __FILE__,__LINE__);
609
/* easy implementation, convert 1 Unicode character at one time. */
610
/* If the open performance is an issue, convert a chunk such as 128 chracters. */
611
/* if the converted length is not the same as the original, convert one by one. */
612
(dmap_rec[idx].dmapU2D)[0x0000]=0x00;
613
for (i = 1; i < 0x10000; ++i) {
615
inBuf=(char *) dmapSrc;
617
outBuf=(char *) &((dmap_rec[idx].dmapU2D)[2*i]);
620
if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
621
if (len == 1 && inBytesLeft == 0 && outBytesLeft == 1 && (dmap_rec[idx].dmapU2D)[2*i] == 0x1A) {
622
/* UCS-2_TIS-620:0x0080 => 0x1A, converted to SBCS replacement character */
623
(dmap_rec[idx].dmapU2D)[2*i+1]=0x00;
625
} else if (len == 1 && inBytesLeft == 0 && outBytesLeft == 0) {
628
if (errno == EILSEQ || errno == EINVAL) {
631
MyPrintf(STDERR_WITH_TIME,
632
"dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
633
to, from, idx, errno, __FILE__,__LINE__);
634
MyPrintf(STDERR_WO_TIME,
635
"iconv(cd,%04x,2,%02x%02x,2) returns inBytesLeft=%d, outBytesLeft=%d\n",
637
(dmap_rec[idx].dmapU2D)[2*i], (dmap_rec[idx].dmapU2D)[2*i+1],
638
inBytesLeft, outBytesLeft);
639
if (outBuf - (char *) dmap_rec[idx].dmapU2M2 > 1)
640
MyPrintf(STDERR_WO_TIME, "outBuf[-2..2]=%02X%02X%02X%02X%02X\n", outBuf[-2],outBuf[-1],outBuf[0],outBuf[1],outBuf[2]);
642
MyPrintf(STDERR_WO_TIME, "outBuf[0..2]=%02X%02X%02X\n", outBuf[0],outBuf[1],outBuf[2]);
647
memcpy(outBuf, (char *) &(myconv_rec[idx].subD), 2);
652
MyPrintf(STDERR_WITH_TIME,
653
"[%d] dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
654
i, to, from, idx, errno, __FILE__,__LINE__);
655
MyPrintf(STDERR_WO_TIME,
656
"iconv(cd,%04x,2,%02x%02x,2) returns %d inBytesLeft=%d, outBytesLeft=%d\n",
658
(dmap_rec[idx].dmapU2D)[2*i],
659
(dmap_rec[idx].dmapU2D)[2*i+1],
660
len, inBytesLeft,outBytesLeft);
662
MyPrintf(STDERR_WO_TIME,
663
" inBuf [-1..2]=%02x%02x%02x%02x\n",
664
inBuf[-1],inBuf[0],inBuf[1],inBuf[2]);
665
MyPrintf(STDERR_WO_TIME,
666
" outBuf [-1..2]=%02x%02x%02x%02x\n",
667
outBuf[-1],outBuf[0],outBuf[1],outBuf[2]);
669
MyPrintf(STDERR_WO_TIME,
670
" inBuf [-2..2]=%02x%02x%02x%02x%02x\n",
671
inBuf[-2],inBuf[-1],inBuf[0],inBuf[1],inBuf[2]);
672
MyPrintf(STDERR_WO_TIME,
673
" outBuf [-2..2]=%02x%02x%02x%02x%02x\n",
674
outBuf[-2],outBuf[-1],outBuf[0],outBuf[1],outBuf[2]);
680
if (len == 0 && inBytesLeft == 0 && outBytesLeft == 1) { /* converted to SBCS */
681
(dmap_rec[idx].dmapU2D)[2*i+1]=0x00;
685
} while (inBytesLeft > 0);
688
myconv_rec[idx].subS = dmap_rec[idx].dmapU2D[2*0x1A];
689
myconv_rec[idx].subD = dmap_rec[idx].dmapU2D[2*0xFFFD] * 0x100
690
+ dmap_rec[idx].dmapU2D[2*0xFFFD+1];
691
myconv_rec[idx].srcSubS = 0x1A;
692
myconv_rec[idx].srcSubD = 0xFFFD;
696
} else if (((myconvIsEUC(from) && myconvIsUnicode2(to)) && (dmap_rec[idx].codingSchema = DMAP_E2U)) ||
697
((myconvIsEUC(from) && myconvIsUTF8(to)) && (dmap_rec[idx].codingSchema = DMAP_E28))) {
699
/* S0: 0x00 - 0x7F */
700
if ((dmap_rec[idx].dmapE02U = (UniChar *) alloc_root(&dmapMemRoot, 0x100 * 2)) == NULL) {
702
MyPrintf(STDERR_WITH_TIME,
703
"dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
704
to, from, idx, DMAP_E2U, errno, __FILE__,__LINE__);
708
memset(dmap_rec[idx].dmapE02U, 0x00, 0x100 * 2);
710
/* S1: 0xA0 - 0xFF, 0xA0 - 0xFF */
711
if ((dmap_rec[idx].dmapE12U = (UniChar *) alloc_root(&dmapMemRoot, 0x60 * 0x60 * 2)) == NULL) {
713
MyPrintf(STDERR_WITH_TIME,
714
"dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
715
to, from, idx, DMAP_E2U, errno, __FILE__,__LINE__);
719
memset(dmap_rec[idx].dmapE12U, 0x00, 0x60 * 0x60 * 2);
721
/* SS2: 0x8E + 0xA0 - 0xFF, 0xA0 - 0xFF */
722
if ((dmap_rec[idx].dmapE22U = (UniChar *) alloc_root(&dmapMemRoot, 0x60 * 0x61 * 2)) == NULL) {
724
MyPrintf(STDERR_WITH_TIME,
725
"dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
726
to, from, idx, DMAP_E2U, errno, __FILE__,__LINE__);
730
memset(dmap_rec[idx].dmapE22U, 0x00, 0x60 * 0x61 * 2);
732
/* SS3: 0x8F + 0xA0 - 0xFF, 0xA0 - 0xFF */
733
if ((dmap_rec[idx].dmapE32U = (UniChar *) alloc_root(&dmapMemRoot, 0x60 * 0x61 * 2)) == NULL) {
735
MyPrintf(STDERR_WITH_TIME,
736
"dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
737
to, from, idx, DMAP_E2U, errno, __FILE__,__LINE__);
741
memset(dmap_rec[idx].dmapE32U, 0x00, 0x60 * 0x61 * 2);
743
myconv_rec[idx].allocatedSize=(0x100 + 0x60 * 0x60 + 0x60 * 0x61* 2) * 2;
747
char dmapSrc[0x60 * 0x60 * 3];
757
#ifdef support_surrogate
758
if ((cd = iconv_open("UTF-16", from)) == (iconv_t) -1) {
760
if ((cd = iconv_open("UCS-2", from)) == (iconv_t) -1) {
763
MyPrintf(STDERR_WITH_TIME,
764
"dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
765
to, from, idx, errno, __FILE__,__LINE__);
770
for (i = 0; i < 0x100; ++i) {
774
outBuf=(char *) (&dmap_rec[idx].dmapE02U[i]);
776
if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
779
MyPrintf(STDERR_WITH_TIME,
780
"dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
781
to, from, idx, errno, __FILE__,__LINE__);
784
dmap_rec[idx].dmapE02U[i]=0x0000;
786
if (dmap_rec[idx].dmapE02U[i] == 0x001A && /* pick the first one */
787
myconv_rec[idx].srcSubS == 0x00) {
788
myconv_rec[idx].srcSubS=i;
794
for (i = 0; i < 0x60; ++i) {
796
for (j = 0; j < 0x60; ++j) {
804
inBytesLeft=0x60 * 0x60 * 2;
805
outBuf=(char *) dmap_rec[idx].dmapE12U;
806
outBytesLeft=0x60 * 0x60 * 2;
808
if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
809
if (errno == EILSEQ) {
812
MyPrintf(STDERR_WITH_TIME,
813
"dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
814
to, from, idx, errno, __FILE__,__LINE__);
815
MyPrintf(STDERR_WO_TIME, "inBytesLeft=%d, outBytesLeft=%d\n", inBytesLeft, outBytesLeft);
816
if (inBuf - dmapSrc > 1 && inBuf - dmapSrc <= sizeof(dmapSrc) - 2)
817
MyPrintf(STDERR_WO_TIME, "inBuf[-2..2]=%02X%02X%02X%02X%02X\n", inBuf[-2],inBuf[-1],inBuf[0],inBuf[1],inBuf[2]);
819
MyPrintf(STDERR_WO_TIME, "inBuf[0..2]=%02X%02X%02X\n", inBuf[0],inBuf[1],inBuf[2]);
820
if (outBuf - (char *) dmap_rec[idx].dmapE12U > 1)
821
MyPrintf(STDERR_WO_TIME, "outBuf[-2..2]=%02X%02X%02X%02X%02X\n", outBuf[-2],outBuf[-1],outBuf[0],outBuf[1],outBuf[2]);
823
MyPrintf(STDERR_WO_TIME, "outBuf[0..2]=%02X%02X%02X\n", outBuf[0],outBuf[1],outBuf[2]);
834
MyPrintf(STDERR_WITH_TIME,
835
"dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
836
to, from, idx, errno, __FILE__,__LINE__);
842
} while (inBytesLeft > 0);
844
/* SS2: 0x8E + 1 or 2 bytes */
845
/* SS3: 0x8E + 1 or 2 bytes */
847
int32_t numSuccess=0;
848
for (i = 0; i < 0x60; ++i) {
854
outBuf=(char *) &(dmap_rec[idx].dmapE22U[i]);
856
outBuf=(char *) &(dmap_rec[idx].dmapE32U[i]);
858
if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
860
dmap_rec[idx].dmapE22U[i]=0x0000;
862
dmap_rec[idx].dmapE32U[i]=0x0000;
867
if (numSuccess == 0) { /* SS2 is 2 bytes */
869
for (i = 0; i < 0x60; ++i) {
871
for (j = 0; j < 0x60; ++j) {
881
inBytesLeft=0x60 * 0x60 * 3;
883
outBuf=(char *) &(dmap_rec[idx].dmapE22U[0x60]);
885
outBuf=(char *) &(dmap_rec[idx].dmapE32U[0x60]);
886
outBytesLeft=0x60 * 0x60 * 2;
888
if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
891
MyPrintf(STDERR_WITH_TIME,
892
"%02X:dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
893
SS, to, from, idx, errno, __FILE__,__LINE__);
894
MyPrintf(STDERR_WO_TIME, "inBytesLeft=%d, outBytesLeft=%d\n", inBytesLeft, outBytesLeft);
895
if (inBuf - dmapSrc > 1 && inBuf - dmapSrc <= sizeof(dmapSrc) - 2)
896
MyPrintf(STDERR_WO_TIME, "inBuf[-2..2]=%02X%02X%02X%02X%02X\n", inBuf[-2],inBuf[-1],inBuf[0],inBuf[1],inBuf[2]);
898
MyPrintf(STDERR_WO_TIME, "inBuf[0..2]=%02X%02X%02X\n", inBuf[0],inBuf[1],inBuf[2]);
901
if (errno == EILSEQ || errno == EINVAL) {
910
MyPrintf(STDERR_WITH_TIME,
911
"%02X:dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
912
SS, to, from, idx, errno, __FILE__,__LINE__);
918
} while (inBytesLeft > 0);
927
myconv_rec[idx].subS=0x1A;
928
myconv_rec[idx].subD=0xFFFD;
929
for (i = 0; i < 0x80; ++i) {
930
if (dmap_rec[idx].dmapE02U[i] == 0x001A) {
931
myconv_rec[idx].srcSubS=i; /* pick the first one */
936
for (i = 0; i < 0x60 * 0x60; ++i) {
937
if (dmap_rec[idx].dmapE12U[i] == 0xFFFD) {
938
uchar byte1=i / 0x60;
939
uchar byte2=i % 0x60;
940
myconv_rec[idx].srcSubD=(byte1 + 0xA0) * 0x100 + (byte2 + 0xA0); /* pick the last one */
946
} else if (((myconvIsUCS2(from) && myconvIsEUC(to)) && (dmap_rec[idx].codingSchema = DMAP_U2E)) ||
947
((myconvIsUTF16(from) && myconvIsEUC(to)) && (dmap_rec[idx].codingSchema = DMAP_T2E)) ||
948
((myconvIsUTF8(from) && myconvIsEUC(to)) && (dmap_rec[idx].codingSchema = DMAP_82E))) {
949
/* S0: 0x00 - 0xFF */
950
if ((dmap_rec[idx].dmapU2S = (uchar *) alloc_root(&dmapMemRoot, 0x100)) == NULL) {
952
MyPrintf(STDERR_WITH_TIME,
953
"dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
954
to, from, idx, DMAP_U2E, errno, __FILE__,__LINE__);
958
memset(dmap_rec[idx].dmapU2S, 0x00, 0x100);
960
/* U0080 - UFFFF -> S1: 0xA0 - 0xFF, 0xA0 - 0xFF */
961
if ((dmap_rec[idx].dmapU2M2 = (uchar *) alloc_root(&dmapMemRoot, 0xFF80 * 2)) == NULL) {
963
MyPrintf(STDERR_WITH_TIME,
964
"dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
965
to, from, idx, DMAP_U2E, errno, __FILE__,__LINE__);
969
memset(dmap_rec[idx].dmapU2M2, 0x00, 0xFF80 * 2);
971
/* U0080 - UFFFF -> SS2: 0x8E + 0xA0 - 0xFF, 0xA0 - 0xFF
972
* SS3: 0x8F + 0xA0 - 0xFF, 0xA0 - 0xFF */
973
if ((dmap_rec[idx].dmapU2M3 = (uchar *) alloc_root(&dmapMemRoot, 0xFF80 * 3)) == NULL) {
975
MyPrintf(STDERR_WITH_TIME,
976
"dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
977
to, from, idx, DMAP_U2E, errno, __FILE__,__LINE__);
981
memset(dmap_rec[idx].dmapU2M3, 0x00, 0xFF80 * 3);
982
myconv_rec[idx].allocatedSize=(0x100 + 0xFF80 * 2 + 0xFF80 * 3);
985
UniChar dmapSrc[0x80];
994
#ifdef support_surrogate
995
if ((cd = iconv_open(to, "UTF-16")) == (iconv_t) -1) {
997
if ((cd = iconv_open(to, "UCS-2")) == (iconv_t) -1) {
1000
MyPrintf(STDERR_WITH_TIME,
1001
"dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
1002
to, from, idx, errno, __FILE__,__LINE__);
1007
for (i = 0; i < 0x80; ++i)
1009
inBuf=(char *) dmapSrc;
1010
inBytesLeft=0x80 * 2;
1011
outBuf=(char *) dmap_rec[idx].dmapU2S;
1014
if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
1016
MyPrintf(STDERR_WITH_TIME,
1017
"dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
1018
to, from, idx, errno, __FILE__,__LINE__);
1023
} while (inBytesLeft > 0);
1025
myconv_rec[idx].srcSubS = 0x1A;
1026
myconv_rec[idx].srcSubD = 0xFFFD;
1027
myconv_rec[idx].subS = dmap_rec[idx].dmapU2S[0x1A];
1029
outBuf=(char *) &(myconv_rec[idx].subD);
1031
inBuf=(char *) dmapSrc;
1034
if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
1037
MyPrintf(STDERR_WITH_TIME,
1038
"dmap_open(%s,%s,%d) failed to initialize with iconv(), rc=%d, errno=%d in %s at %d\n",
1039
to, from, idx, len, errno, __FILE__,__LINE__);
1040
MyPrintf(STDERR_WO_TIME, "iconv(0x1A,1,%p,1) returns outBuf=%p, outBytesLeft=%d\n",
1041
dmapSrc, outBuf, outBytesLeft);
1044
if (outBytesLeft == 0) {
1045
/* UCS-2_IBM-eucKR returns error.
1046
myconv(iconv) rc=1, error=0, InBytesLeft=0, OutBytesLeft=18
1047
myconv(iconvRev) rc=-1, error=116, InBytesLeft=2, OutBytesLeft=20
1048
iconv: 0xFFFD => 0xAFFE => 0x rc=1,-1 sub=0,0
1057
for (i = 0x80; i < 0xFFFF; ++i) {
1060
inBuf=(char *) dmapSrc;
1062
outBuf=(char *) eucBuf;
1063
outBytesLeft=sizeof(eucBuf);
1065
if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
1066
if (len == 1 && errno == 0 && inBytesLeft == 0 && outBytesLeft == 1) { /* substitution occurred. */ continue;
1069
if (errno == EILSEQ) {
1072
MyPrintf(STDERR_WITH_TIME,
1073
"dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
1074
to, from, idx, errno, __FILE__,__LINE__);
1075
MyPrintf(STDERR_WO_TIME, "inBytesLeft=%d, outBytesLeft=%d\n", inBytesLeft, outBytesLeft);
1076
if (inBuf - (char *) dmapSrc > 1 && inBuf - (char *) dmapSrc <= sizeof(dmapSrc) - 2)
1077
MyPrintf(STDERR_WO_TIME, "inBuf[-2..2]=%02X%02X%02X%02X%02X\n", inBuf[-2],inBuf[-1],inBuf[0],inBuf[1],inBuf[2]);
1079
MyPrintf(STDERR_WO_TIME, "inBuf[0..2]=%02X%02X%02X\n", inBuf[0],inBuf[1],inBuf[2]);
1080
if (outBuf - (char *) dmap_rec[idx].dmapU2M2 > 1)
1081
MyPrintf(STDERR_WO_TIME, "outBuf[-2..2]=%02X%02X%02X%02X%02X\n", outBuf[-2],outBuf[-1],outBuf[0],outBuf[1],outBuf[2]);
1083
MyPrintf(STDERR_WO_TIME, "outBuf[0..2]=%02X%02X%02X\n", outBuf[0],outBuf[1],outBuf[2]);
1088
memcpy(outBuf, (char *) &(myconv_rec[idx].subD), 2);
1094
MyPrintf(STDERR_WITH_TIME,
1095
"dmap_open(%s,%s,%d) failed to initialize with iconv(), rc = %d, errno = %d in %s at %d\n",
1096
to, from, idx, len, errno, __FILE__,__LINE__);
1097
MyPrintf(STDERR_WITH_TIME,
1098
"%04X: src=%04X%04X, inBuf=0x%02X%02X, inBytesLeft=%d, outBuf[-2..0]=%02X%02X%02X, outBytesLeft=%d\n",
1099
i, dmapSrc[0], dmapSrc[1], inBuf[0], inBuf[1],
1100
inBytesLeft, outBuf[-2], outBuf[-1], outBuf[0], outBytesLeft);
1101
MyPrintf(STDERR_WITH_TIME,
1102
"&dmapSrc=%p, inBuf=%p, dmapU2M2 + %d = %p, outBuf=%p\n",
1103
dmapSrc, inBuf, (i - 0x80) * 2, dmap_rec[idx].dmapU2M2 + (i - 0x80) * 2, outBuf);
1110
if (sizeof(eucBuf) - outBytesLeft == 1) {
1112
(dmap_rec[idx].dmapU2S)[i]=eucBuf[0];
1114
dmap_rec[idx].dmapU2M2[(i - 0x80) * 2] = eucBuf[0];
1115
dmap_rec[idx].dmapU2M2[(i - 0x80) * 2 + 1] = 0x00;
1117
} else if (sizeof(eucBuf) - outBytesLeft == 2) { /* 2 bytes */
1118
dmap_rec[idx].dmapU2M2[(i - 0x80) * 2] = eucBuf[0];
1119
dmap_rec[idx].dmapU2M2[(i - 0x80) * 2 + 1] = eucBuf[1];
1120
} else if (sizeof(eucBuf) - outBytesLeft == 3) { /* 3 byte SS2/SS3 */
1121
dmap_rec[idx].dmapU2M3[(i - 0x80) * 3] = eucBuf[0];
1122
dmap_rec[idx].dmapU2M3[(i - 0x80) * 3 + 1] = eucBuf[1];
1123
dmap_rec[idx].dmapU2M3[(i - 0x80) * 3 + 2] = eucBuf[2];
1127
MyPrintf(STDERR_WITH_TIME,
1128
"dmap_open(%s,%s,%d) failed to initialize with iconv(), rc=%d, errno=%d in %s at %d\n",
1129
to, from, idx, len, errno, __FILE__,__LINE__);
1130
MyPrintf(STDERR_WITH_TIME,
1131
"%04X: src=%04X%04X, inBuf=0x%02X%02X, inBytesLeft=%d, outBuf=%02X%02X%02X, outBytesLeft=%d\n",
1132
i, dmapSrc[0], dmapSrc[1], inBuf[0], inBuf[1],
1133
inBytesLeft, outBuf[-2], outBuf[-1], outBuf[0], outBytesLeft);
1134
MyPrintf(STDERR_WITH_TIME,
1135
"&dmapSrc=%p, inBuf=%p, %p, outBuf=%p\n",
1136
dmapSrc, inBuf, dmap_rec[idx].dmapU2M3 + (i - 0x80) * 2, outBuf);
1146
} else if (myconvIsUTF16(from) && myconvIsUTF8(to)) {
1147
dmap_rec[idx].codingSchema = DMAP_T28;
1149
} else if (myconvIsUCS2(from) && myconvIsUTF8(to)) {
1150
dmap_rec[idx].codingSchema = DMAP_U28;
1152
} else if (myconvIsUTF8(from) && myconvIsUnicode2(to)) {
1153
dmap_rec[idx].codingSchema = DMAP_82U;
1155
} else if (myconvIsUnicode2(from) && myconvIsUnicode2(to)) {
1156
dmap_rec[idx].codingSchema = DMAP_U2U;
1162
myconv_rec[idx].cnv_dmap=&(dmap_rec[idx]);
1168
static int bins_open(const char * to,
1177
static int32_t dmap_close(const int32_t idx)
1179
if (dmap_rec[idx].codingSchema == DMAP_S2S) {
1180
if (dmap_rec[idx].dmapS2S != NULL) {
1181
dmap_rec[idx].dmapS2S=NULL;
1183
} else if (dmap_rec[idx].codingSchema = DMAP_E2U) {
1184
if (dmap_rec[idx].dmapE02U != NULL) {
1185
dmap_rec[idx].dmapE02U=NULL;
1187
if (dmap_rec[idx].dmapE12U != NULL) {
1188
dmap_rec[idx].dmapE12U=NULL;
1190
if (dmap_rec[idx].dmapE22U != NULL) {
1191
dmap_rec[idx].dmapE22U=NULL;
1193
if (dmap_rec[idx].dmapE32U != NULL) {
1194
dmap_rec[idx].dmapE32U=NULL;
1202
static int32_t bins_close(const int32_t idx)
1208
myconv_t myconv_open(const char * toCode,
1209
const char * fromCode,
1213
for (i = 0; i < MAX_CONVERTER; ++i) {
1214
if (myconv_rec[i].converterType == 0)
1217
if (i >= MAX_CONVERTER)
1218
return ((myconv_t) -1);
1220
myconv_rec[i].converterType = converter;
1221
myconv_rec[i].index=i;
1222
myconv_rec[i].fromCcsid=cstoccsid(fromCode);
1223
if (myconv_rec[i].fromCcsid == 0 && memcmp(fromCode, "big5",5) == 0)
1224
myconv_rec[i].fromCcsid=950;
1225
myconv_rec[i].toCcsid=cstoccsid(toCode);
1226
if (myconv_rec[i].toCcsid == 0 && memcmp(toCode, "big5",5) == 0)
1227
myconv_rec[i].toCcsid=950;
1228
strncpy(myconv_rec[i].from, fromCode, sizeof(myconv_rec[i].from)-1);
1229
strncpy(myconv_rec[i].to, toCode, sizeof(myconv_rec[i].to)-1);
1231
if (converter == CONVERTER_ICONV) {
1232
if ((myconv_rec[i].cnv_iconv=iconv_open(toCode, fromCode)) == (iconv_t) -1) {
1233
return ((myconv_t) -1);
1235
myconv_rec[i].allocatedSize = -1;
1236
myconv_rec[i].srcSubS=myconvGetSubS(fromCode);
1237
myconv_rec[i].srcSubD=myconvGetSubD(fromCode);
1238
myconv_rec[i].subS=myconvGetSubS(toCode);
1239
myconv_rec[i].subD=myconvGetSubD(toCode);
1240
return &(myconv_rec[i]);
1241
} else if (converter == CONVERTER_DMAP &&
1242
dmap_open(toCode, fromCode, i) != -1) {
1243
return &(myconv_rec[i]);
1245
return ((myconv_t) -1);
1250
int32_t myconv_close(myconv_t cd)
1254
if (cd->converterType == CONVERTER_ICONV) {
1255
ret=iconv_close(cd->cnv_iconv);
1256
} else if (cd->converterType == CONVERTER_DMAP) {
1257
ret=dmap_close(cd->index);
1259
memset(&(myconv_rec[cd->index]), 0x00, sizeof(myconv_rec[cd->index]));
1266
/* reference: http://www-306.ibm.com/software/globalization/other/es.jsp */
1267
/* systemCL would be expensive, and myconvIsXXXXX is called frequently.
1268
need to cache entries */
1269
#define MAX_CCSID 256
1270
static int ccsidList [MAX_CCSID];
1271
static int esList [MAX_CCSID];
1272
int32 getEncodingScheme(const uint16 inCcsid, int32& outEncodingScheme);
1273
EXTERN int myconvGetES(CCSID ccsid)
1275
/* call QtqValidateCCSID in ILE to get encoding schema */
1276
/* return QtqValidateCCSID(ccsid); */
1278
for (i = 0; i < MAX_CCSID; ++i) {
1279
if (ccsidList[i] == ccsid)
1281
if (ccsidList[i] == 0x00)
1285
if (i >= MAX_CCSID) {
1291
getEncodingScheme(ccsid, esList[i]);
1294
fprintf(stderr, "CCSID=%d, ES=0x%04X\n", ccsid, esList[i]);
1303
EXTERN int myconvIsEBCDIC(const char * pName)
1305
int es = myconvGetES(cstoccsid(pName));
1317
EXTERN int myconvIsISO(const char * pName)
1319
int es = myconvGetES(cstoccsid(pName));
1336
EXTERN int myconvIsASCII(const char * pName)
1338
int es = myconvGetES(cstoccsid(pName));
1351
} else if (memcmp(pName, "big5", 5) == 0) {
1359
EXTERN int myconvIsUCS2(const char * pName)
1361
if (cstoccsid(pName) == 13488) {
1368
EXTERN int myconvIsUTF16(const char * pName)
1370
if (cstoccsid(pName) == 1200) {
1377
EXTERN int myconvIsUnicode2(const char * pName)
1379
int es = myconvGetES(cstoccsid(pName));
1389
EXTERN int myconvIsUTF8(const char * pName)
1391
int es = myconvGetES(cstoccsid(pName));
1399
EXTERN int myconvIsUnicode(const char * pName)
1401
int es = myconvGetES(cstoccsid(pName));
1412
EXTERN int myconvIsEUC(const char * pName)
1414
int es = myconvGetES(cstoccsid(pName));
1422
EXTERN int myconvIsDBCS(const char * pName)
1424
int es = myconvGetES(cstoccsid(pName));
1436
} else if (memcmp(pName, "big5", 5) == 0) {
1443
EXTERN int myconvIsSBCS(const char * pName)
1445
int es = myconvGetES(cstoccsid(pName));
1462
EXTERN char myconvGetSubS(const char * code)
1464
if (myconvIsEBCDIC(code)) {
1466
} else if (myconvIsASCII(code)) {
1468
} else if (myconvIsISO(code)) {
1470
} else if (myconvIsEUC(code)) {
1472
} else if (myconvIsUCS2(code)) {
1474
} else if (myconvIsUTF8(code)) {
1481
EXTERN UniChar myconvGetSubD(const char * code)
1483
if (myconvIsEBCDIC(code)) {
1485
} else if (myconvIsASCII(code)) {
1487
} else if (myconvIsISO(code)) {
1489
} else if (myconvIsEUC(code)) {
1491
} else if (myconvIsUCS2(code)) {
1493
} else if (myconvIsUTF8(code)) {