1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/********************************************************************
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * COPYRIGHT:
327f654740f2a26ad62a5c155af9199af9e69b889claireho * Copyright (c) 1997-2010, International Business Machines Corporation and
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * others. All Rights Reserved.
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ********************************************************************/
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru********************************************************************************
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* File NCCBTST.C
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Modification History:
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*        Name                            Description
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*    Madhu Katragadda     7/21/1999      Testing error callback routines
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru********************************************************************************
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <stdio.h>
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <stdlib.h>
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <string.h>
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <ctype.h>
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "cstring.h"
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/uloc.h"
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/ucnv.h"
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/ucnv_err.h"
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "cintltst.h"
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utypes.h"
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/ustring.h"
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "nccbtst.h"
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/ucnv_cb.h"
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define NEW_MAX_BUFFER 999
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define nct_min(x,y)  ((x<y) ? x : y)
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define ARRAY_LENGTH(array) (sizeof(array)/sizeof((array)[0]))
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic int32_t  gInBufferSize = 0;
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic int32_t  gOutBufferSize = 0;
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic char     gNuConvTestName[1024];
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void printSeq(const uint8_t* a, int len)
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int i=0;
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("\n{");
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    while (i<len)
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("0x%02X, ", a[i++]);
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("}\n");
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void printUSeq(const UChar* a, int len)
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int i=0;
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("{");
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    while (i<len)
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("  0x%04x, ", a[i++]);
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("}\n");
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void printSeqErr(const uint8_t* a, int len)
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int i=0;
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    fprintf(stderr, "{");
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    while (i<len)
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        fprintf(stderr, "  0x%02x, ", a[i++]);
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    fprintf(stderr, "}\n");
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void printUSeqErr(const UChar* a, int len)
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int i=0;
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    fprintf(stderr, "{");
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    while (i<len)
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        fprintf(stderr, "0x%04x, ", a[i++]);
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    fprintf(stderr,"}\n");
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void setNuConvTestName(const char *codepage, const char *direction)
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    sprintf(gNuConvTestName, "[testing %s %s Unicode, InputBufSiz=%d, OutputBufSiz=%d]",
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            codepage,
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            direction,
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            (int)gInBufferSize,
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            (int)gOutBufferSize);
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestCallBackFailure(void);
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruvoid addTestConvertErrorCallBack(TestNode** root);
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruvoid addTestConvertErrorCallBack(TestNode** root)
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    addTest(root, &TestSkipCallBack,  "tsconv/nccbtst/TestSkipCallBack");
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    addTest(root, &TestStopCallBack,  "tsconv/nccbtst/TestStopCallBack");
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    addTest(root, &TestSubCallBack,   "tsconv/nccbtst/TestSubCallBack");
92ea1f1813c8b13a850b13f256aeb5152bb0942e81claireho    /* BEGIN android-removed
93ea1f1813c8b13a850b13f256aeb5152bb0942e81claireho       To save space, Android does not build complete CJK conversion tables.
94ea1f1813c8b13a850b13f256aeb5152bb0942e81claireho       We skip the test here.
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    addTest(root, &TestSubWithValueCallBack, "tsconv/nccbtst/TestSubWithValueCallBack");
96ea1f1813c8b13a850b13f256aeb5152bb0942e81claireho       END android-removed */
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    addTest(root, &TestLegalAndOtherCallBack,  "tsconv/nccbtst/TestLegalAndOtherCallBack");
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    addTest(root, &TestSingleByteCallBack,  "tsconv/nccbtst/TestSingleByteCallBack");
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    addTest(root, &TestCallBackFailure,  "tsconv/nccbtst/TestCallBackFailure");
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestSkipCallBack()
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSkip(NEW_MAX_BUFFER, NEW_MAX_BUFFER);
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSkip(1,NEW_MAX_BUFFER);
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSkip(1,1);
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSkip(NEW_MAX_BUFFER, 1);
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestStopCallBack()
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestStop(NEW_MAX_BUFFER, NEW_MAX_BUFFER);
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestStop(1,NEW_MAX_BUFFER);
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestStop(1,1);
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestStop(NEW_MAX_BUFFER, 1);
120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestSubCallBack()
123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSub(NEW_MAX_BUFFER, NEW_MAX_BUFFER);
125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSub(1,NEW_MAX_BUFFER);
126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSub(1,1);
127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSub(NEW_MAX_BUFFER, 1);
128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestEBCDIC_STATEFUL_Sub(1, 1);
131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestEBCDIC_STATEFUL_Sub(1, NEW_MAX_BUFFER);
132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestEBCDIC_STATEFUL_Sub(NEW_MAX_BUFFER, 1);
133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestEBCDIC_STATEFUL_Sub(NEW_MAX_BUFFER, NEW_MAX_BUFFER);
134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestSubWithValueCallBack()
138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSubWithValue(NEW_MAX_BUFFER, NEW_MAX_BUFFER);
140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSubWithValue(1,NEW_MAX_BUFFER);
141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSubWithValue(1,1);
142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSubWithValue(NEW_MAX_BUFFER, 1);
143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestLegalAndOtherCallBack()
147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestLegalAndOthers(NEW_MAX_BUFFER, NEW_MAX_BUFFER);
149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestLegalAndOthers(1,NEW_MAX_BUFFER);
150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestLegalAndOthers(1,1);
151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestLegalAndOthers(NEW_MAX_BUFFER, 1);
152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestSingleByteCallBack()
155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSingleByte(NEW_MAX_BUFFER, NEW_MAX_BUFFER);
157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSingleByte(1,NEW_MAX_BUFFER);
158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSingleByte(1,1);
159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    TestSingleByte(NEW_MAX_BUFFER, 1);
160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestSkip(int32_t inputsize, int32_t outputsize)
164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t expskipIBM_949[]= {
166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x00, 0xb0, 0xa1, 0xb0, 0xa2, 0xc8, 0xd3 };
167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t expskipIBM_943[] = {
169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x9f, 0xaf, 0x9f, 0xb1, 0x89, 0x59 };
170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t expskipIBM_930[] = {
172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x0e, 0x5d, 0x5f, 0x5d, 0x63, 0x46, 0x6b, 0x0f };
173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gInBufferSize = inputsize;
175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gOutBufferSize = outputsize;
176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*From Unicode*/
178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_SKIP  \n");
179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar   sampleText[] =  { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 };
183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar  sampleText2[] =  { 0x6D63, 0x6D64, 0x6D65, 0x6D66 };
184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t  toIBM949Offsskip [] = { 0, 1, 1, 2, 2, 4, 4 };
186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t  toIBM943Offsskip [] = { 0, 0, 1, 1, 3, 3 };
187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                expskipIBM_949, sizeof(expskipIBM_949), "ibm-949",
190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, toIBM949Offsskip, NULL, 0 ))
191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> ibm-949 with skip did not match.\n");
192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                expskipIBM_943, sizeof(expskipIBM_943), "ibm-943",
194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, toIBM943Offsskip, NULL, 0 ))
195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> ibm-943 with skip did not match.\n");
196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar fromU[] = { 0x61, 0xff5e, 0x62, 0x6d63, 0xff5e, 0x6d64, 0x63, 0xff5e, 0x6d66 };
200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t fromUBytes[] = { 0x62, 0x63, 0x0e, 0x5d, 0x5f, 0x5d, 0x63, 0x0f, 0x64, 0x0e, 0x46, 0x6b, 0x0f };
201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t fromUOffsets[] = { 0, 2, 3, 3, 3, 5, 5, 6, 6, 8, 8, 8, 8 };
202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* test ibm-930 (EBCDIC_STATEFUL) with fallbacks that are not taken to check correct state transitions */
204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(fromU, sizeof(fromU)/U_SIZEOF_UCHAR,
205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   fromUBytes, sizeof(fromUBytes),
206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   "ibm-930",
207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   UCNV_FROM_U_CALLBACK_SKIP, fromUOffsets,
208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   NULL, 0)
209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u->ibm-930 with skip with untaken fallbacks did not match.\n");
211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar usasciiFromU[] = { 0x61, 0x80, 0x4e00, 0x31, 0xd800, 0xdfff, 0x39 };
217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t usasciiFromUBytes[] = { 0x61, 0x31, 0x39 };
218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t usasciiFromUOffsets[] = { 0, 3, 6 };
219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar latin1FromU[] = { 0x61, 0xa0, 0x4e00, 0x31, 0xd800, 0xdfff, 0x39 };
221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t latin1FromUBytes[] = { 0x61, 0xa0, 0x31, 0x39 };
222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t latin1FromUOffsets[] = { 0, 1, 3, 6 };
223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* US-ASCII */
225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(usasciiFromU, sizeof(usasciiFromU)/U_SIZEOF_UCHAR,
226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   usasciiFromUBytes, sizeof(usasciiFromUBytes),
227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   "US-ASCII",
228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   UCNV_FROM_U_CALLBACK_SKIP, usasciiFromUOffsets,
229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   NULL, 0)
230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u->US-ASCII with skip did not match.\n");
232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* SBCS NLTC codepage 367 for US-ASCII */
236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(usasciiFromU, sizeof(usasciiFromU)/U_SIZEOF_UCHAR,
237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   usasciiFromUBytes, sizeof(usasciiFromUBytes),
238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   "ibm-367",
239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   UCNV_FROM_U_CALLBACK_SKIP, usasciiFromUOffsets,
240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   NULL, 0)
241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u->ibm-367 with skip did not match.\n");
243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* ISO-Latin-1 */
247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(latin1FromU, sizeof(latin1FromU)/U_SIZEOF_UCHAR,
248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   latin1FromUBytes, sizeof(latin1FromUBytes),
249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   "LATIN_1",
250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   UCNV_FROM_U_CALLBACK_SKIP, latin1FromUOffsets,
251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   NULL, 0)
252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u->LATIN_1 with skip did not match.\n");
254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* windows-1252 */
258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(latin1FromU, sizeof(latin1FromU)/U_SIZEOF_UCHAR,
259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   latin1FromUBytes, sizeof(latin1FromUBytes),
260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   "windows-1252",
261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   UCNV_FROM_U_CALLBACK_SKIP, latin1FromUOffsets,
262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   NULL, 0)
263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u->windows-1252 with skip did not match.\n");
265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 };
270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t toIBM943[]= { 0x61, 0x61 };
271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offset[]= {0, 4};
272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru         /* EUC_JP*/
274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar euc_jp_inputText[]={ 0x0061, 0x4edd, 0x5bec, 0xd801, 0xdc01, 0xd801, 0x0061, 0x00a2 };
275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae,
276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0x8e, 0xe0,
277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t fromEUC_JPOffs [] ={ 0, 1, 1, 2, 2, 2, 6, 7, 7};
279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*EUC_TW*/
281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar euc_tw_inputText[]={ 0x0061, 0x2295, 0x5BF2, 0xd801, 0xdc01, 0xd801, 0x0061, 0x8706, 0x8a, };
282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_euc_tw[]={
283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5,
284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0xe6, 0xca, 0x8a,
285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_euc_twOffs [] ={ 0, 1, 1, 2, 2, 2, 2, 6, 7, 7, 8,};
287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISO-2022-JP*/
289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_jp_inputText[]={0x0041, 0x00E9/*unassigned*/,0x0042, };
290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_jp[]={
291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,
293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_jpOffs [] ={0,2};
296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISO-2022-JP*/
298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar const iso_2022_jp_inputText2[]={0x0041, 0x00E9/*unassigned*/,0x43,0xd800/*illegal*/,0x0042, };
299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_jp2[]={
300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x43,
302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_jpOffs2 [] ={0,2};
305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISO-2022-cn*/
307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_cn_inputText[]={ 0x0041, 0x3712/*unassigned*/, 0x0042, };
308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_cn[]={
309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41, 0x42
310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_cnOffs [] ={
312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0, 2
313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISO-2022-CN*/
316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_cn_inputText1[]={0x0041, 0x3712/*unassigned*/,0x43,0xd800/*illegal*/,0x0042, };
317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_cn1[]={
318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41, 0x43
319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_cnOffs1 [] ={ 0, 2 };
322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISO-2022-kr*/
324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_kr_inputText[]={ 0x0041, 0x03A0,0x3712/*unassigned*/,0x03A0, 0x0042, };
325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_kr[]={
326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1b,   0x24,   0x29,   0x43,
327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0e,   0x25,   0x50,
329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,   0x50,
330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0f,   0x42,
331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_krOffs [] ={
333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            -1,-1,-1,-1,
334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,
335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,
336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3,3,
337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            4,4
338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISO-2022-kr*/
341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_kr_inputText1[]={ 0x0041, 0x03A0,0x3712/*unassigned*/,0x03A0,0xd801/*illegal*/, 0x0042, };
342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_kr1[]={
343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1b,   0x24,   0x29,   0x43,
344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0e,   0x25,   0x50,
346ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,   0x50,
347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_krOffs1 [] ={
350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            -1,-1,-1,-1,
351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,
352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,
353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3,3,
354ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
355ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* HZ encoding */
357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar hz_inputText[]={ 0x0041, 0x03A0,0x0662/*unassigned*/,0x03A0, 0x0042, };
358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_hz[]={
360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d,   0x41,
361ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7b,   0x26,   0x30,
362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x26,   0x30,
363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d,   0x42,
364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
365ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
366ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_hzOffs [] ={
367ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,0,0,
368ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,1,
369ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3,3,
370ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            4,4,4,4
371ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
372ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
373ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar hz_inputText1[]={ 0x0041, 0x03A0,0x0662/*unassigned*/,0x03A0,0xd801/*illegal*/, 0x0042, };
374ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
375ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_hz1[]={
376ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d,   0x41,
377ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7b,   0x26,   0x30,
378ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x26,   0x30,
379ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
380ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
381ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
382ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_hzOffs1 [] ={
383ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,0,0,
384ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,1,
385ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3,3,
386ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
387ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
388ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
389ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
390ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
391ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar SCSU_inputText[]={ 0x0041, 0xd801/*illegal*/, 0x0042, };
392ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
393ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_SCSU[]={
394ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
395ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42
396ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
397ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
398ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
399ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_SCSUOffs [] ={
400ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,
401ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            2,
402ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
403ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
404ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
405ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
406ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* ISCII */
407ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iscii_inputText[]={ 0x0041, 0x3712/*unassigned*/, 0x0042, };
408ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iscii[]={
409ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
410ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,
411ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
412ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_isciiOffs [] ={
413ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,2,
414ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
415ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
416ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISCII*/
417ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iscii_inputText1[]={0x0044, 0x3712/*unassigned*/,0x43,0xd800/*illegal*/,0x0042, };
418ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iscii1[]={
419ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x44,
420ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x43,
421ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
422ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
423ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_isciiOffs1 [] ={0,2};
424ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
425ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(inputTest, sizeof(inputTest)/sizeof(inputTest[0]),
426ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                toIBM943, sizeof(toIBM943), "ibm-943",
427ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, offset, NULL, 0 ))
428ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> ibm-943 with skip did not match.\n");
429ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
430ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]),
431ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_euc_jp, sizeof(to_euc_jp), "euc-jp",
432ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, fromEUC_JPOffs, NULL, 0 ))
433ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> euc-jp with skip did not match.\n");
434ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
435ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(euc_tw_inputText, sizeof(euc_tw_inputText)/sizeof(euc_tw_inputText[0]),
436ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_euc_tw, sizeof(to_euc_tw), "euc-tw",
437ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, from_euc_twOffs, NULL, 0 ))
438ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> euc-tw with skip did not match.\n");
439ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
440ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*iso_2022_jp*/
441ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_jp_inputText, sizeof(iso_2022_jp_inputText)/sizeof(iso_2022_jp_inputText[0]),
442ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_jp, sizeof(to_iso_2022_jp), "iso-2022-jp",
443ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, from_iso_2022_jpOffs, NULL, 0 ))
444ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso-2022-jp with skip did not match.\n");
445ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
446ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* with context */
447ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicodeWithContext(iso_2022_jp_inputText2, sizeof(iso_2022_jp_inputText2)/sizeof(iso_2022_jp_inputText2[0]),
448ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_jp2, sizeof(to_iso_2022_jp2), "iso-2022-jp",
449ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, from_iso_2022_jpOffs2, NULL, 0,UCNV_SKIP_STOP_ON_ILLEGAL,U_ILLEGAL_CHAR_FOUND ))
450ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso-2022-jp with skip & UCNV_SKIP_STOP_ON_ILLEGAL did not match.\n");
451ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
452ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*iso_2022_cn*/
453ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_cn_inputText, sizeof(iso_2022_cn_inputText)/sizeof(iso_2022_cn_inputText[0]),
454ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_cn, sizeof(to_iso_2022_cn), "iso-2022-cn",
455ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, from_iso_2022_cnOffs, NULL, 0 ))
456ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso-2022-cn with skip did not match.\n");
457ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*with context*/
458ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicodeWithContext(iso_2022_cn_inputText1, sizeof(iso_2022_cn_inputText1)/sizeof(iso_2022_cn_inputText1[0]),
459ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_cn1, sizeof(to_iso_2022_cn1), "iso-2022-cn",
460ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, from_iso_2022_cnOffs1, NULL, 0,UCNV_SKIP_STOP_ON_ILLEGAL,U_ILLEGAL_CHAR_FOUND ))
461ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso-2022-cn with skip & UCNV_SKIP_STOP_ON_ILLEGAL did not match.\n");
462ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
463ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*iso_2022_kr*/
464ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_kr_inputText, sizeof(iso_2022_kr_inputText)/sizeof(iso_2022_kr_inputText[0]),
465ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_kr, sizeof(to_iso_2022_kr), "iso-2022-kr",
466ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, from_iso_2022_krOffs, NULL, 0 ))
467ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso-2022-kr with skip did not match.\n");
468ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          /*with context*/
469ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicodeWithContext(iso_2022_kr_inputText1, sizeof(iso_2022_kr_inputText1)/sizeof(iso_2022_kr_inputText1[0]),
470ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_kr1, sizeof(to_iso_2022_kr1), "iso-2022-kr",
471ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, from_iso_2022_krOffs1, NULL, 0,UCNV_SKIP_STOP_ON_ILLEGAL,U_ILLEGAL_CHAR_FOUND ))
472ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso-2022-kr with skip & UCNV_SKIP_STOP_ON_ILLEGAL did not match.\n");
473ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
474ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*hz*/
475ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(hz_inputText, sizeof(hz_inputText)/sizeof(hz_inputText[0]),
476ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_hz, sizeof(to_hz), "HZ",
477ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, from_hzOffs, NULL, 0 ))
478ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> HZ with skip did not match.\n");
479ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          /*with context*/
480ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicodeWithContext(hz_inputText1, sizeof(hz_inputText1)/sizeof(hz_inputText1[0]),
481ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_hz1, sizeof(to_hz1), "hz",
482ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, from_hzOffs1, NULL, 0,UCNV_SKIP_STOP_ON_ILLEGAL,U_ILLEGAL_CHAR_FOUND ))
483ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> hz with skip & UCNV_SKIP_STOP_ON_ILLEGAL did not match.\n");
484ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
485ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
486ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*SCSU*/
487ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(SCSU_inputText, sizeof(SCSU_inputText)/sizeof(SCSU_inputText[0]),
488ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_SCSU, sizeof(to_SCSU), "SCSU",
489ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, from_SCSUOffs, NULL, 0 ))
490ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> SCSU with skip did not match.\n");
491ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
492ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
493ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISCII*/
494ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iscii_inputText, sizeof(iscii_inputText)/sizeof(iscii_inputText[0]),
495ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iscii, sizeof(to_iscii), "ISCII,version=0",
496ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, from_isciiOffs, NULL, 0 ))
497ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iscii with skip did not match.\n");
498ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*with context*/
499ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicodeWithContext(iscii_inputText1, sizeof(iscii_inputText1)/sizeof(iscii_inputText1[0]),
500ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iscii1, sizeof(to_iscii1), "ISCII,version=0",
501ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SKIP, from_isciiOffs1, NULL, 0,UCNV_SKIP_STOP_ON_ILLEGAL,U_ILLEGAL_CHAR_FOUND ))
502ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iscii with skip & UCNV_SKIP_STOP_ON_ILLEGAL did not match.\n");
503ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
504ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
505ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
506ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing fromUnicode for BOCU-1 with UCNV_TO_U_CALLBACK_SKIP\n");
507ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
508ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleText[]={ /* from cintltst/bocu1tst.c/TestBOCU1 text 1 */
509ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFB, 0xEE, 0x28,       /* from source offset 0 */
510ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x24, 0x1E, 0x52,
511ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xB2,
512ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,
513ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xB3,
514ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xB1,
515ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0D,
516ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0A,
517ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
518ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,                   /* from 8 */
519ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x00,
520ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xD0, 0x6C,
521ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xB6,
522ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xD8, 0xA5,
523ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,
524ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x68,
525ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x59,
526ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
527ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xF9, 0x28,             /* from 16 */
528ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x6D,
529ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,
530ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x73,
531ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xE0, 0x2D,
532ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xDE, 0x43,
533ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xD0, 0x33,
534ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,
535ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
536ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFA, 0x83,             /* from 24 */
537ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25, 0x01,
538ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFB, 0x16, 0x87,
539ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x4B, 0x16,
540ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,
541ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xE6, 0xBD,
542ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xEB, 0x5B,
543ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x4B, 0xCC,
544ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
545ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xF9, 0xA2,             /* from 32 */
546ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFC, 0x10, 0x3E,
547ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFE, 0x16, 0x3A, 0x8C,
548ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,
549ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFC, 0x03, 0xAC,
550ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
551ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x01,                   /* from 41 */
552ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xDE, 0x83,
553ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,
554ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x09
555ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
556ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar expected[]={
557ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFEFF, 0x0061, 0x0062, 0x0020, /* 0 */
558ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0063, 0x0061, 0x000D, 0x000A,
559ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
560ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0020, 0x0000, 0x00DF, 0x00E6, /* 8 */
561ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0930, 0x0020, 0x0918, 0x0909,
562ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
563ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x3086, 0x304D, 0x0020, 0x3053, /* 16 */
564ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x4000, 0x4E00, 0x7777, 0x0020,
565ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
566ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x9FA5, 0x4E00, 0xAC00, 0xBCDE, /* 24 */
567ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0020, 0xD7A3, 0xDC00, 0xD800,
568ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
569ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xD800, 0xDC00, 0xD845, 0xDDDD, /* 32 */
570ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xDBBB, 0xDDEE, 0x0020, 0xDBFF,
571ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
572ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xDFFF, 0x0001, 0x0E40, 0x0020, /* 40 */
573ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0009
574ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
575ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offsets[]={
576ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0, 0, 0, 1, 1, 1, 2, 3, 4, 5, 6, 7,
577ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            8, 9, 10, 10, 11, 12, 12, 13, 14, 15,
578ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            16, 16, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23,
579ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            24, 24, 25, 25, 26, 26, 26, 27, 27, 28, 29, 29, 30, 30, 31, 31,
580ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            32, 32, 34, 34, 34, 36, 36, 36, 36, 38, 39, 39, 39,
581ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            41, 42, 42, 43, 44
582ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
583ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
584ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* BOCU-1 fromUnicode never calls callbacks, so this only tests single-byte and offsets behavior */
585ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(expected, ARRAY_LENGTH(expected),
586ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 sampleText, sizeof(sampleText),
587ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 "BOCU-1",
588ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_FROM_U_CALLBACK_SKIP, offsets, NULL, 0)
589ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
590ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u->BOCU-1 with skip did not match.\n");
591ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
592ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
593ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
594ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing fromUnicode for CESU-8 with UCNV_TO_U_CALLBACK_SKIP\n");
595ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
596ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const uint8_t sampleText[]={
597ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61,                               /* 'a' */
598ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xc4, 0xb5,                         /* U+0135 */
599ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xed, 0x80, 0xa0,                   /* Hangul U+d020 */
600ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xed, 0xa0, 0x81, 0xed, 0xb0, 0x81, /* surrogate pair for U+10401 */
601ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xee, 0x80, 0x80,                   /* PUA U+e000 */
602ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xed, 0xb0, 0x81,                   /* unpaired trail surrogate U+dc01 */
603ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x62,                               /* 'b' */
604ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xed, 0xa0, 0x81,                   /* unpaired lead surrogate U+d801 */
605ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xd0, 0x80                          /* U+0400 */
606ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
607ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar expected[]={
608ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0061,
609ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0135,
610ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xd020,
611ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xd801, 0xdc01,
612ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xe000,
613ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xdc01,
614ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0062,
615ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xd801,
616ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0400
617ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
618ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t offsets[]={
619ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,
620ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1, 1,
621ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            2, 2, 2,
622ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3, 3, 3, 4, 4, 4,
623ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            5, 5, 5,
624ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            6, 6, 6,
625ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            7,
626ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            8, 8, 8,
627ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            9, 9
628ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
629ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
630ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* CESU-8 fromUnicode never calls callbacks, so this only tests conversion and offsets behavior */
631ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
632ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* without offsets */
633ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(expected, ARRAY_LENGTH(expected),
634ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 sampleText, sizeof(sampleText),
635ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 "CESU-8",
636ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_FROM_U_CALLBACK_SKIP, NULL, NULL, 0)
637ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
638ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u->CESU-8 with skip did not match.\n");
639ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
640ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
641ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* with offsets */
642ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(expected, ARRAY_LENGTH(expected),
643ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 sampleText, sizeof(sampleText),
644ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 "CESU-8",
645ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_FROM_U_CALLBACK_SKIP, offsets, NULL, 0)
646ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
647ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u->CESU-8 with skip did not match.\n");
648ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
649ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
650ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
651ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*to Unicode*/
652ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_SKIP  \n");
653ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
654ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
655ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
656ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
657ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar IBM_949skiptoUnicode[]= {0x0000, 0xAC00, 0xAC01, 0xD700 };
658ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar IBM_943skiptoUnicode[]= { 0x6D63, 0x6D64, 0x6D66 };
659ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar IBM_930skiptoUnicode[]= { 0x6D63, 0x6D64, 0x6D66 };
660ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
661ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t  fromIBM949Offs [] = { 0, 1, 3, 5};
662ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t  fromIBM943Offs [] = { 0, 2, 4};
663ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t  fromIBM930Offs [] = { 1, 3, 5};
664ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
665ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(expskipIBM_949, sizeof(expskipIBM_949),
666ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 IBM_949skiptoUnicode, sizeof(IBM_949skiptoUnicode)/sizeof(IBM_949skiptoUnicode),"ibm-949",
667ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, fromIBM949Offs, NULL, 0 ))
668ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("ibm-949->u with skip did not match.\n");
669ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(expskipIBM_943, sizeof(expskipIBM_943),
670ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 IBM_943skiptoUnicode, sizeof(IBM_943skiptoUnicode)/sizeof(IBM_943skiptoUnicode[0]),"ibm-943",
671ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, fromIBM943Offs, NULL, 0 ))
672ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("ibm-943->u with skip did not match.\n");
673ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
674ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
675ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(expskipIBM_930, sizeof(expskipIBM_930),
676ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 IBM_930skiptoUnicode, sizeof(IBM_930skiptoUnicode)/sizeof(IBM_930skiptoUnicode[0]),"ibm-930",
677ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, fromIBM930Offs, NULL, 0 ))
678ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("ibm-930->u with skip did not match.\n");
679ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
680ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
681ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicodeWithContext(expskipIBM_930, sizeof(expskipIBM_930),
682ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 IBM_930skiptoUnicode, sizeof(IBM_930skiptoUnicode)/sizeof(IBM_930skiptoUnicode[0]),"ibm-930",
683ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, fromIBM930Offs, NULL, 0,"i",U_ILLEGAL_CHAR_FOUND ))
684ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("ibm-930->u with skip did not match.\n");
685ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
686ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
687ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
688ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
689ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t usasciiToUBytes[] = { 0x61, 0x80, 0x31 };
690ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar usasciiToU[] = { 0x61, 0x31 };
691ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t usasciiToUOffsets[] = { 0, 2 };
692ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
693ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t latin1ToUBytes[] = { 0x61, 0xa0, 0x31 };
694ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar latin1ToU[] = { 0x61, 0xa0, 0x31 };
695ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t latin1ToUOffsets[] = { 0, 1, 2 };
696ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
697ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* US-ASCII */
698ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(usasciiToUBytes, sizeof(usasciiToUBytes),
699ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 usasciiToU, sizeof(usasciiToU)/U_SIZEOF_UCHAR,
700ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 "US-ASCII",
701ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SKIP, usasciiToUOffsets,
702ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 NULL, 0)
703ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
704ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("US-ASCII->u with skip did not match.\n");
705ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
706ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
707ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
708ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* SBCS NLTC codepage 367 for US-ASCII */
709ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(usasciiToUBytes, sizeof(usasciiToUBytes),
710ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 usasciiToU, sizeof(usasciiToU)/U_SIZEOF_UCHAR,
711ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 "ibm-367",
712ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SKIP, usasciiToUOffsets,
713ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 NULL, 0)
714ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
715ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("ibm-367->u with skip did not match.\n");
716ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
717ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
718ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
719ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* ISO-Latin-1 */
720ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(latin1ToUBytes, sizeof(latin1ToUBytes),
721ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 latin1ToU, sizeof(latin1ToU)/U_SIZEOF_UCHAR,
722ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 "LATIN_1",
723ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SKIP, latin1ToUOffsets,
724ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 NULL, 0)
725ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
726ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("LATIN_1->u with skip did not match.\n");
727ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
728ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
729ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
730ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* windows-1252 */
731ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(latin1ToUBytes, sizeof(latin1ToUBytes),
732ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 latin1ToU, sizeof(latin1ToU)/U_SIZEOF_UCHAR,
733ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 "windows-1252",
734ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SKIP, latin1ToUOffsets,
735ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 NULL, 0)
736ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
737ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("windows-1252->u with skip did not match.\n");
738ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
739ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
740ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
741ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
742ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
743ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
744ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxtEBCIDIC_STATEFUL [] ={
745ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0e, 0x5d, 0x5f , 0x41, 0x79, 0x41, 0x44
746ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
747ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar EBCIDIC_STATEFUL_toUnicode[] ={  0x6d63, 0x03b4
748ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
749ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_EBCIDIC_STATEFULOffsets []={ 1, 5};
750ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
751ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
752ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru         /* euc-jp*/
753ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae,
75485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* BEGIN android-changed */
75585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* Android uses a different EUC-JP table. We change this byte sequence,
75685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho             * choosing one that is unassigned in both tables. */
75785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            0x8f, 0xa1, 0xa1,  /*unassigned*/
75885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* 0x8f, 0xda, 0xa1, */ /*unassigned*/
75985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* END android-changed */
760ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru           0x8e, 0xe0,
761ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
762ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar euc_jptoUnicode[]={ 0x0061, 0x4edd, 0x5bec, 0x00a2};
763ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_euc_jpOffs [] ={ 0, 1, 3, 9};
764ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
765ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru         /*EUC_TW*/
766ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_euc_tw[]={ 0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5,
767ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x8e, 0xaa, 0xbb, 0xcc,/*unassigned*/
768ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru           0xe6, 0xca, 0x8a,
769ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
770ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar euc_twtoUnicode[]={ 0x0061, 0x2295, 0x5BF2, 0x8706, 0x8a, };
771ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_euc_twOffs [] ={ 0, 1, 3, 11, 13};
772ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                /*iso-2022-jp*/
773ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_iso_2022_jp[]={
774ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
775ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1b,   0x24,   0x42,   0x2A, 0x44, /*unassigned*/
776ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             0x1b,   0x28,   0x42,   0x42,
777ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
778ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
779ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_jptoUnicode[]={    0x41,0x42 };
780ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_jpOffs [] ={  0,9   };
781ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
782ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*iso-2022-cn*/
783ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_iso_2022_cn[]={
784ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0f,   0x41,   0x44,
785ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1B,   0x24,   0x29,   0x47,
786ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0E,   0x40,   0x6f, /*unassigned*/
787ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0f,   0x42,
788ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
789ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
790ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
791ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_cntoUnicode[]={    0x41, 0x44,0x42 };
792ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_cnOffs [] ={  1,   2,   11   };
793ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
794ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*iso-2022-kr*/
795ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_iso_2022_kr[]={
796ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          0x1b, 0x24, 0x29,  0x43,
797ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          0x41,
798ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          0x0E, 0x7f, 0x1E,
799ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          0x0e, 0x25, 0x50,
800ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          0x0f, 0x51,
801ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          0x42, 0x43,
802ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
803ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
804ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_krtoUnicode[]={     0x41,0x03A0,0x51, 0x42,0x43};
805ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_krOffs [] ={  4,    9,    12,   13  , 14 };
806ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
807ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*hz*/
808ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_hz[]={
809ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
810ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7b,   0x26,   0x30,
811ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7f,   0x1E, /*unassigned*/
812ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x26,   0x30,
813ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d,   0x42,
814ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7b,   0x7f,   0x1E,/*unassigned*/
815ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d,   0x42,
816ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
817ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar hztoUnicode[]={
818ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
819ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x03a0,
820ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x03A0,
821ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,
822ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,};
823ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
824ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_hzOffs [] ={0,3,7,11,18,  };
825ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
826ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISCII*/
827ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_iscii[]={
828ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
829ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xa1,
830ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xEB,    /*unassigned*/
831ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x26,
832ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x30,
833ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xa2,
834ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xEC,    /*unassigned*/
835ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,
836ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
837ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar isciitoUnicode[]={
838ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
839ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0901,
840ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x26,
841ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x30,
842ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0902,
843ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,
844ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            };
845ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
846ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_isciiOffs [] ={0,1,3,4,5,7 };
847ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
848ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*LMBCS*/
849ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxtLMBCS[]={ 0x12, 0xc9, 0x50,
850ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x12, 0x92, 0xa0, /*unassigned*/
851ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x12, 0x92, 0xA1,
852ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
853ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar LMBCSToUnicode[]={ 0x4e2e, 0xe5c4};
854ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t fromLMBCS[] = {0, 6};
855ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
856ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxtEBCIDIC_STATEFUL, sizeof(sampleTxtEBCIDIC_STATEFUL),
857ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             EBCIDIC_STATEFUL_toUnicode, sizeof(EBCIDIC_STATEFUL_toUnicode)/sizeof(EBCIDIC_STATEFUL_toUnicode[0]),"ibm-930",
858ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_SKIP, from_EBCIDIC_STATEFULOffsets, NULL, 0 ))
859ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("EBCIDIC_STATEFUL->u with skip did not match.\n");
860ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
861ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicodeWithContext(sampleTxtEBCIDIC_STATEFUL, sizeof(sampleTxtEBCIDIC_STATEFUL),
862ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             EBCIDIC_STATEFUL_toUnicode, sizeof(EBCIDIC_STATEFUL_toUnicode)/sizeof(EBCIDIC_STATEFUL_toUnicode[0]),"ibm-930",
863ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_SKIP, from_EBCIDIC_STATEFULOffsets, NULL, 0,"i",U_ILLEGAL_CHAR_FOUND ))
864ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("EBCIDIC_STATEFUL->u with skip did not match.\n");
865ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
866ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp),
867ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp",
868ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, from_euc_jpOffs , NULL, 0))
869ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("euc-jp->u with skip did not match.\n");
870ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
871ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
872ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
873ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_euc_tw, sizeof(sampleTxt_euc_tw),
874ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 euc_twtoUnicode, sizeof(euc_twtoUnicode)/sizeof(euc_twtoUnicode[0]),"euc-tw",
875ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, from_euc_twOffs , NULL, 0))
876ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("euc-tw->u with skip did not match.\n");
877ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
878ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
879ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_iso_2022_jp, sizeof(sampleTxt_iso_2022_jp),
880ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 iso_2022_jptoUnicode, sizeof(iso_2022_jptoUnicode)/sizeof(iso_2022_jptoUnicode[0]),"iso-2022-jp",
881ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, from_iso_2022_jpOffs , NULL, 0))
882ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("iso-2022-jp->u with skip did not match.\n");
883ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
884ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_iso_2022_cn, sizeof(sampleTxt_iso_2022_cn),
885ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 iso_2022_cntoUnicode, sizeof(iso_2022_cntoUnicode)/sizeof(iso_2022_cntoUnicode[0]),"iso-2022-cn",
886ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, from_iso_2022_cnOffs , NULL, 0))
887ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("iso-2022-cn->u with skip did not match.\n");
888ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
889ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_iso_2022_kr, sizeof(sampleTxt_iso_2022_kr),
890ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 iso_2022_krtoUnicode, sizeof(iso_2022_krtoUnicode)/sizeof(iso_2022_krtoUnicode[0]),"iso-2022-kr",
891ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, from_iso_2022_krOffs , NULL, 0))
892ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("iso-2022-kr->u with skip did not match.\n");
893ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
894ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_hz, sizeof(sampleTxt_hz),
895ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 hztoUnicode, sizeof(hztoUnicode)/sizeof(hztoUnicode[0]),"HZ",
896ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, from_hzOffs , NULL, 0))
897ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("HZ->u with skip did not match.\n");
898ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
899ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_iscii, sizeof(sampleTxt_iscii),
900ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 isciitoUnicode, sizeof(isciitoUnicode)/sizeof(isciitoUnicode[0]),"ISCII,version=0",
901ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, from_isciiOffs , NULL, 0))
902ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("iscii->u with skip did not match.\n");
903ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
904ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxtLMBCS, sizeof(sampleTxtLMBCS),
905ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                LMBCSToUnicode, sizeof(LMBCSToUnicode)/sizeof(LMBCSToUnicode[0]),"LMBCS-1",
906ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, fromLMBCS , NULL, 0))
907ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("LMBCS->u with skip did not match.\n");
908ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
909ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
910ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
911ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
912ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing to Unicode for UTF-8 with UCNV_TO_U_CALLBACK_SKIP \n");
913ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
914ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c,
915ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xe0, 0x80,  0x61,};
916ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar    expected1[] = {  0x0031, 0x4e8c, 0x0061};
917ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t offsets1[] = {   0x0000, 0x0001, 0x0006};
918ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
919ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleText1, sizeof(sampleText1),
920ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 expected1, sizeof(expected1)/sizeof(expected1[0]),"utf8",
921ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, offsets1, NULL, 0 ))
922ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("utf8->u with skip did not match.\n");;
923ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
924ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
925ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing toUnicode for SCSU with UCNV_TO_U_CALLBACK_SKIP \n");
926ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
927ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const uint8_t sampleText1[] = {  0xba, 0x8c,0xF8, 0x61,0x0c, 0x0c,};
928ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar    expected1[] = {  0x00ba,  0x008c,  0x00f8,  0x0061,0xfffe,0xfffe};
929ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t offsets1[] = {   0x0000, 0x0001,0x0002,0x0003,4,5};
930ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
931ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleText1, sizeof(sampleText1),
932ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 expected1, sizeof(expected1)/sizeof(expected1[0]),"SCSU",
933ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SKIP, offsets1, NULL, 0 ))
934ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("scsu->u with skip did not match.\n");
935ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
936ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
937ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing toUnicode for BOCU-1 with UCNV_TO_U_CALLBACK_SKIP\n");
938ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
939ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const uint8_t sampleText[]={ /* modified from cintltst/bocu1tst.c/TestBOCU1 text 1 */
940ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFB, 0xEE, 0x28,       /* single-code point sequence at offset 0 */
941ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x24, 0x1E, 0x52,       /* 3 */
942ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xB2,                   /* 6 */
943ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,                   /* 7 */
944ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x40, 0x07,             /* 8 - wrong trail byte */
945ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xB3,                   /* 10 */
946ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xB1,                   /* 11 */
947ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xD0, 0x20,             /* 12 - wrong trail byte */
948ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0D,                   /* 14 */
949ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0A,                   /* 15 */
950ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,                   /* 16 */
951ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x00,                   /* 17 */
952ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xD0, 0x6C,             /* 18 */
953ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xB6,                   /* 20 */
954ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xD8, 0xA5,             /* 21 */
955ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,                   /* 23 */
956ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x68,                   /* 24 */
957ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x59,                   /* 25 */
958ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xF9, 0x28,             /* 26 */
959ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x6D,                   /* 28 */
960ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,                   /* 29 */
961ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x73,                   /* 30 */
962ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xE0, 0x2D,             /* 31 */
963ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xDE, 0x43,             /* 33 */
964ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xD0, 0x33,             /* 35 */
965ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,                   /* 37 */
966ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFA, 0x83,             /* 38 */
967ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25, 0x01,             /* 40 */
968ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFB, 0x16, 0x87,       /* 42 */
969ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x4B, 0x16,             /* 45 */
970ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,                   /* 47 */
971ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xE6, 0xBD,             /* 48 */
972ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xEB, 0x5B,             /* 50 */
973ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x4B, 0xCC,             /* 52 */
974ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xF9, 0xA2,             /* 54 */
975ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFC, 0x10, 0x3E,       /* 56 */
976ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFE, 0x16, 0x3A, 0x8C, /* 59 */
977ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,                   /* 63 */
978ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFC, 0x03, 0xAC,       /* 64 */
979ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFF,                   /* 67 - FF just resets the state without encoding anything */
980ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x01,                   /* 68 */
981ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xDE, 0x83,             /* 69 */
982ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,                   /* 71 */
983ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x09                    /* 72 */
984ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
985ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar expected[]={
986ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xFEFF, 0x0061, 0x0062, 0x0020,
987ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0063, 0x0061, 0x000D, 0x000A,
988ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0020, 0x0000, 0x00DF, 0x00E6,
989ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0930, 0x0020, 0x0918, 0x0909,
990ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x3086, 0x304D, 0x0020, 0x3053,
991ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x4000, 0x4E00, 0x7777, 0x0020,
992ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x9FA5, 0x4E00, 0xAC00, 0xBCDE,
993ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0020, 0xD7A3, 0xDC00, 0xD800,
994ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xD800, 0xDC00, 0xD845, 0xDDDD,
995ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xDBBB, 0xDDEE, 0x0020, 0xDBFF,
996ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xDFFF, 0x0001, 0x0E40, 0x0020,
997ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0009
998ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
999ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t offsets[]={
1000ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0, 3, 6, 7, /* skip 8, */
1001ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            10, 11, /* skip 12, */
1002ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            14, 15, 16, 17, 18,
1003ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            20, 21, 23, 24, 25, 26, 28, 29,
1004ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            30, 31, 33, 35, 37, 38,
1005ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            40, 42, 45, 47, 48,
1006ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            50, 52, 54, /* trail */ 54, 56, /* trail */ 56, 59, /* trail */ 59,
1007ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            63, 64, /* trail */ 64, /* reset only 67, */
1008ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            68, 69,
1009ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            71, 72
1010ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1011ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1012ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleText, sizeof(sampleText),
1013ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 expected, ARRAY_LENGTH(expected), "BOCU-1",
1014ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SKIP, offsets, NULL, 0)
1015ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1016ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("BOCU-1->u with skip did not match.\n");
1017ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1018ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1019ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1020ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing toUnicode for CESU-8 with UCNV_TO_U_CALLBACK_SKIP\n");
1021ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1022ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const uint8_t sampleText[]={
1023ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61,                               /* 0  'a' */
1024ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xc0, 0x80,                         /* 1  non-shortest form */
1025ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xc4, 0xb5,                         /* 3  U+0135 */
1026ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xed, 0x80, 0xa0,                   /* 5  Hangul U+d020 */
1027ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xed, 0xa0, 0x81, 0xed, 0xb0, 0x81, /* 8  surrogate pair for U+10401 */
1028ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xee, 0x80, 0x80,                   /* 14 PUA U+e000 */
1029ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xed, 0xb0, 0x81,                   /* 17 unpaired trail surrogate U+dc01 */
1030ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xf0, 0x90, 0x80, 0x80,             /* 20 illegal 4-byte form for U+10000 */
1031ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x62,                               /* 24 'b' */
1032ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xed, 0xa0, 0x81,                   /* 25 unpaired lead surrogate U+d801 */
1033ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xed, 0xa0,                         /* 28 incomplete sequence */
1034ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xd0, 0x80                          /* 30 U+0400 */
1035ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1036ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar expected[]={
1037ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0061,
1038ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            /* skip */
1039ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0135,
1040ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xd020,
1041ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xd801, 0xdc01,
1042ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xe000,
1043ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xdc01,
1044ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            /* skip */
1045ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0062,
1046ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xd801,
1047ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0400
1048ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1049ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t offsets[]={
1050ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,
1051ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            /* skip 1, */
1052ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3,
1053ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            5,
1054ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            8, 11,
1055ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            14,
1056ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            17,
1057ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            /* skip 20, 20, */
1058ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            24,
1059ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            25,
1060ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            /* skip 28 */
1061ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            30
1062ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1063ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1064ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* without offsets */
1065ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleText, sizeof(sampleText),
1066ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 expected, ARRAY_LENGTH(expected), "CESU-8",
1067ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SKIP, NULL, NULL, 0)
1068ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1069ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("CESU-8->u with skip did not match.\n");
1070ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1071ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1072ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* with offsets */
1073ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleText, sizeof(sampleText),
1074ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 expected, ARRAY_LENGTH(expected), "CESU-8",
1075ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SKIP, offsets, NULL, 0)
1076ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1077ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("CESU-8->u with skip did not match.\n");
1078ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1079ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1080ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
1081ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1082ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestStop(int32_t inputsize, int32_t outputsize)
1083ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
1084ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const UChar   sampleText[] =  { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 };
1085ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const UChar  sampleText2[] =  { 0x6D63, 0x6D64, 0x6D65, 0x6D66 };
1086ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1087ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t expstopIBM_949[]= {
1088ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x00, 0xb0, 0xa1, 0xb0, 0xa2};
1089ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1090ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t expstopIBM_943[] = {
1091ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x9f, 0xaf, 0x9f, 0xb1};
1092ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1093ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t expstopIBM_930[] = {
1094ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x0e, 0x5d, 0x5f, 0x5d, 0x63};
1095ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1096ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const UChar IBM_949stoptoUnicode[]= {0x0000, 0xAC00, 0xAC01};
1097ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const UChar IBM_943stoptoUnicode[]= { 0x6D63, 0x6D64};
1098ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const UChar IBM_930stoptoUnicode[]= { 0x6D63, 0x6D64};
1099ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t  toIBM949Offsstop [] = { 0, 1, 1, 2, 2};
1102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t  toIBM943Offsstop [] = { 0, 0, 1, 1};
1103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t  toIBM930Offsstop [] = { 0, 0, 0, 1, 1};
1104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t  fromIBM949Offs [] = { 0, 1, 3};
1106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t  fromIBM943Offs [] = { 0, 2};
1107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t  fromIBM930Offs [] = { 1, 3};
1108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gInBufferSize = inputsize;
1110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gOutBufferSize = outputsize;
1111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*From Unicode*/
1113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
1115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
1116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            expstopIBM_949, sizeof(expstopIBM_949), "ibm-949",
1117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_FROM_U_CALLBACK_STOP, toIBM949Offsstop, NULL, 0 ))
1118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("u-> ibm-949 with stop did not match.\n");
1119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
1120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            expstopIBM_943, sizeof(expstopIBM_943), "ibm-943",
1121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_FROM_U_CALLBACK_STOP, toIBM943Offsstop , NULL, 0))
1122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("u-> ibm-943 with stop did not match.\n");
1123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
1124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            expstopIBM_930, sizeof(expstopIBM_930), "ibm-930",
1125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_FROM_U_CALLBACK_STOP, toIBM930Offsstop, NULL, 0 ))
1126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("u-> ibm-930 with stop did not match.\n");
1127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_STOP  \n");
1129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 };
1131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t toIBM943[]= { 0x61,};
1132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offset[]= {0,} ;
1133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru         /*EUC_JP*/
1135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar euc_jp_inputText[]={ 0x0061, 0x4edd, 0x5bec, 0xd801, 0xdc01, 0xd801, 0x0061, 0x00a2 };
1136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae,};
1137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t fromEUC_JPOffs [] ={ 0, 1, 1, 2, 2, 2,};
1138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*EUC_TW*/
1140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar euc_tw_inputText[]={ 0x0061, 0x2295, 0x5BF2, 0xd801, 0xdc01, 0xd801, 0x0061, 0x8706, 0x8a, };
1141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_euc_tw[]={
1142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5,};
1143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_euc_twOffs [] ={ 0, 1, 1, 2, 2, 2, 2,};
1144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISO-2022-JP*/
1146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_jp_inputText[]={0x0041, 0x00E9, 0x0042, };
1147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_jp[]={
1148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             0x41,
1149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_jpOffs [] ={0,};
1152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISO-2022-cn*/
1154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_cn_inputText[]={ 0x0041, 0x3712, 0x0042, };
1155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_cn[]={
1156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
1157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_cnOffs [] ={
1160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,0,
1161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            2,2,
1162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISO-2022-kr*/
1165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_kr_inputText[]={ 0x0041, 0x03A0,0x3712/*unassigned*/,0x03A0, 0x0042, };
1166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_kr[]={
1167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1b,   0x24,   0x29,   0x43,
1168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
1169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0e,   0x25,   0x50,
1170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_krOffs [] ={
1172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            -1,-1,-1,-1,
1173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             0,
1174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,
1175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* HZ encoding */
1178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar hz_inputText[]={ 0x0041, 0x03A0,0x0662/*unassigned*/,0x03A0, 0x0042, };
1179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_hz[]={
1181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d, 0x41,
1182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7b,   0x26,   0x30,
1183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_hzOffs [] ={
1186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0, 0,0,
1187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,1,
1188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISCII*/
1191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iscii_inputText[]={ 0x0041, 0x3712, 0x0042, };
1192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iscii[]={
1193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
1194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_isciiOffs [] ={
1196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,
1197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(inputTest, sizeof(inputTest)/sizeof(inputTest[0]),
1200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                toIBM943, sizeof(toIBM943), "ibm-943",
1201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_STOP, offset, NULL, 0 ))
1202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> ibm-943 with stop did not match.\n");
1203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]),
1205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_euc_jp, sizeof(to_euc_jp), "euc-jp",
1206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_STOP, fromEUC_JPOffs, NULL, 0 ))
1207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> euc-jp with stop did not match.\n");
1208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(euc_tw_inputText, sizeof(euc_tw_inputText)/sizeof(euc_tw_inputText[0]),
1210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_euc_tw, sizeof(to_euc_tw), "euc-tw",
1211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_STOP, from_euc_twOffs, NULL, 0 ))
1212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> euc-tw with stop did not match.\n");
1213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_jp_inputText, sizeof(iso_2022_jp_inputText)/sizeof(iso_2022_jp_inputText[0]),
1215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_jp, sizeof(to_iso_2022_jp), "iso-2022-jp",
1216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_STOP, from_iso_2022_jpOffs, NULL, 0 ))
1217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso-2022-jp with stop did not match.\n");
1218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_jp_inputText, sizeof(iso_2022_jp_inputText)/sizeof(iso_2022_jp_inputText[0]),
1220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_jp, sizeof(to_iso_2022_jp), "iso-2022-jp",
1221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_STOP, from_iso_2022_jpOffs, NULL, 0 ))
1222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso-2022-jp with stop did not match.\n");
1223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_cn_inputText, sizeof(iso_2022_cn_inputText)/sizeof(iso_2022_cn_inputText[0]),
1225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_cn, sizeof(to_iso_2022_cn), "iso-2022-cn",
1226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_STOP, from_iso_2022_cnOffs, NULL, 0 ))
1227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso-2022-cn with stop did not match.\n");
1228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_kr_inputText, sizeof(iso_2022_kr_inputText)/sizeof(iso_2022_kr_inputText[0]),
1230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_kr, sizeof(to_iso_2022_kr), "iso-2022-kr",
1231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_STOP, from_iso_2022_krOffs, NULL, 0 ))
1232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso-2022-kr with stop did not match.\n");
1233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(hz_inputText, sizeof(hz_inputText)/sizeof(hz_inputText[0]),
1235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_hz, sizeof(to_hz), "HZ",
1236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_STOP, from_hzOffs, NULL, 0 ))
1237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> HZ with stop did not match.\n");\
1238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iscii_inputText, sizeof(iscii_inputText)/sizeof(iscii_inputText[0]),
1240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iscii, sizeof(to_iscii), "ISCII,version=0",
1241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_STOP, from_isciiOffs, NULL, 0 ))
1242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iscii with stop did not match.\n");
1243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
1247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing fromUnicode for SCSU with UCNV_FROM_U_CALLBACK_STOP \n");
1249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar SCSU_inputText[]={ 0x0041, 0xd801/*illegal*/, 0x0042, };
1251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_SCSU[]={
1253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
1254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t from_SCSUOffs [] ={
1257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,
1258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(SCSU_inputText, sizeof(SCSU_inputText)/sizeof(SCSU_inputText[0]),
1261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_SCSU, sizeof(to_SCSU), "SCSU",
1262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_STOP, from_SCSUOffs, NULL, 0 ))
1263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> SCSU with skip did not match.\n");
1264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*to Unicode*/
1268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
1270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertToUnicode(expstopIBM_949, sizeof(expstopIBM_949),
1271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             IBM_949stoptoUnicode, sizeof(IBM_949stoptoUnicode)/sizeof(IBM_949stoptoUnicode[0]),"ibm-949",
1272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_STOP, fromIBM949Offs, NULL, 0 ))
1273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("ibm-949->u with stop did not match.\n");
1274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertToUnicode(expstopIBM_943, sizeof(expstopIBM_943),
1275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             IBM_943stoptoUnicode, sizeof(IBM_943stoptoUnicode)/sizeof(IBM_943stoptoUnicode[0]),"ibm-943",
1276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_STOP, fromIBM943Offs, NULL, 0 ))
1277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("ibm-943->u with stop did not match.\n");
1278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertToUnicode(expstopIBM_930, sizeof(expstopIBM_930),
1279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             IBM_930stoptoUnicode, sizeof(IBM_930stoptoUnicode)/sizeof(IBM_930stoptoUnicode[0]),"ibm-930",
1280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_STOP, fromIBM930Offs, NULL, 0 ))
1281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("ibm-930->u with stop did not match.\n");
1282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_STOP \n");
1284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxtEBCIDIC_STATEFUL [] ={
1287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0e, 0x5d, 0x5f , 0x41, 0x79, 0x41, 0x44
1288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar EBCIDIC_STATEFUL_toUnicode[] ={  0x6d63 };
1290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_EBCIDIC_STATEFULOffsets []={ 1};
1291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru         /*EUC-JP*/
1293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae,
129485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* BEGIN android-changed */
129585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* Android uses a different EUC-JP table. We change this byte sequence,
129685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho             * choosing one that is unassigned in both tables. */
129785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            0x8f, 0xa1, 0xa1,  /*unassigned*/
129885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* 0x8f, 0xda, 0xa1, */ /*unassigned*/
129985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* END android-changed */
1300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru           0x8e, 0xe0,
1301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar euc_jptoUnicode[]={ 0x0061, 0x4edd, 0x5bec};
1303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_euc_jpOffs [] ={ 0, 1, 3};
1304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          /*EUC_TW*/
1306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_euc_tw[]={ 0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5,
1307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x8e, 0xaa, 0xbb, 0xcc,/*unassigned*/
1308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru           0xe6, 0xca, 0x8a,
1309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar euc_twtoUnicode[]={ 0x0061, 0x2295, 0x5BF2};
1311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t from_euc_twOffs [] ={ 0, 1, 3};
1312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru         if(!testConvertToUnicode(sampleTxtEBCIDIC_STATEFUL, sizeof(sampleTxtEBCIDIC_STATEFUL),
1316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             EBCIDIC_STATEFUL_toUnicode, sizeof(EBCIDIC_STATEFUL_toUnicode)/sizeof(EBCIDIC_STATEFUL_toUnicode[0]),"ibm-930",
1317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_STOP, from_EBCIDIC_STATEFULOffsets, NULL, 0 ))
1318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("EBCIDIC_STATEFUL->u with stop did not match.\n");
1319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp),
1321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp",
1322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_STOP, from_euc_jpOffs , NULL, 0))
1323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("euc-jp->u with stop did not match.\n");
1324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_euc_tw, sizeof(sampleTxt_euc_tw),
1326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 euc_twtoUnicode, sizeof(euc_twtoUnicode)/sizeof(euc_twtoUnicode[0]),"euc-tw",
1327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_STOP, from_euc_twOffs, NULL, 0 ))
1328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("euc-tw->u with stop did not match.\n");
1329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
1331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing toUnicode for UTF-8 with UCNV_TO_U_CALLBACK_STOP \n");
1333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c,
1335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xe0, 0x80,  0x61,};
1336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar    expected1[] = {  0x0031, 0x4e8c,};
1337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offsets1[] = {   0x0000, 0x0001};
1338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleText1, sizeof(sampleText1),
1340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 expected1, sizeof(expected1)/sizeof(expected1[0]),"utf8",
1341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_STOP, offsets1, NULL, 0 ))
1342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("utf8->u with stop did not match.\n");;
1343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing toUnicode for SCSU with UCNV_TO_U_CALLBACK_STOP \n");
1345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1346ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleText1[] = {  0xba, 0x8c,0xF8, 0x61,0x0c, 0x0c,0x04};
1347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar    expected1[] = {  0x00ba,  0x008c,  0x00f8,  0x0061};
1348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offsets1[] = {   0x0000, 0x0001,0x0002,0x0003};
1349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleText1, sizeof(sampleText1),
1351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 expected1, sizeof(expected1)/sizeof(expected1[0]),"SCSU",
1352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_STOP, offsets1, NULL, 0 ))
1353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("scsu->u with stop did not match.\n");;
1354ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1355ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
1357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestSub(int32_t inputsize, int32_t outputsize)
1359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
1360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const UChar   sampleText[] =  { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 };
1361ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const UChar sampleText2[]=    { 0x6D63, 0x6D64, 0x6D65, 0x6D66 };
1362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t expsubIBM_949[] =
1364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     { 0x00, 0xb0, 0xa1, 0xb0, 0xa2, 0xaf, 0xfe, 0xc8, 0xd3 };
1365ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1366ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t expsubIBM_943[] = {
1367ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x9f, 0xaf, 0x9f, 0xb1, 0xfc, 0xfc, 0x89, 0x59 };
1368ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1369ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t expsubIBM_930[] = {
1370ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x0e, 0x5d, 0x5f, 0x5d, 0x63, 0xfe, 0xfe, 0x46, 0x6b, 0x0f };
1371ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1372ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const UChar IBM_949subtoUnicode[]= {0x0000, 0xAC00, 0xAC01, 0xfffd, 0xD700 };
1373ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const UChar IBM_943subtoUnicode[]= {0x6D63, 0x6D64, 0xfffd, 0x6D66 };
1374ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const UChar IBM_930subtoUnicode[]= {0x6D63, 0x6D64, 0xfffd, 0x6D66 };
1375ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1376ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t toIBM949Offssub [] ={ 0, 1, 1, 2, 2, 3, 3, 4, 4 };
1377ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t toIBM943Offssub [] ={ 0, 0, 1, 1, 2, 2, 3, 3 };
1378ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t toIBM930Offssub [] ={ 0, 0, 0, 1, 1, 2, 2, 3, 3, 3 };
1379ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1380ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t  fromIBM949Offs [] = { 0, 1, 3, 5, 7 };
1381ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t  fromIBM943Offs [] = { 0, 2, 4, 6 };
1382ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t  fromIBM930Offs [] = { 1, 3, 5, 7 };
1383ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1384ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gInBufferSize = inputsize;
1385ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gOutBufferSize = outputsize;
1386ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1387ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*from unicode*/
1388ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1389ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
1390ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
1391ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            expsubIBM_949, sizeof(expsubIBM_949), "ibm-949",
1392ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_FROM_U_CALLBACK_SUBSTITUTE, toIBM949Offssub, NULL, 0 ))
1393ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("u-> ibm-949 with subst did not match.\n");
1394ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
1395ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            expsubIBM_943, sizeof(expsubIBM_943), "ibm-943",
1396ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_FROM_U_CALLBACK_SUBSTITUTE, toIBM943Offssub , NULL, 0))
1397ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("u-> ibm-943 with subst did not match.\n");
1398ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
1399ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            expsubIBM_930, sizeof(expsubIBM_930), "ibm-930",
1400ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_FROM_U_CALLBACK_SUBSTITUTE, toIBM930Offssub, NULL, 0 ))
1401ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("u-> ibm-930 with subst did not match.\n");
1402ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1403ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_SUBSTITUTE  \n");
1404ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1405ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 };
1406ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t toIBM943[]= { 0x61, 0xfc, 0xfc, 0xfc, 0xfc, 0x61 };
1407ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offset[]= {0, 1, 1, 3, 3, 4};
1408ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1409ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1410ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* EUC_JP*/
1411ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar euc_jp_inputText[]={ 0x0061, 0x4edd, 0x5bec, 0xd801, 0xdc01, 0xd801, 0x0061, 0x00a2 };
1412ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae,
1413ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xf4, 0xfe, 0xf4, 0xfe,
1414ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0x8e, 0xe0,
1415ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1416ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t fromEUC_JPOffs [] ={ 0, 1, 1, 2, 2, 2, 3, 3, 5, 5, 6, 7, 7};
1417ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1418ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*EUC_TW*/
1419ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar euc_tw_inputText[]={ 0x0061, 0x2295, 0x5BF2, 0xd801, 0xdc01, 0xd801, 0x0061, 0x8706, 0x8a, };
1420ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_euc_tw[]={
1421ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5,
1422ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xfd, 0xfe, 0xfd, 0xfe,
1423ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0xe6, 0xca, 0x8a,
1424ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1425ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1426ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_euc_twOffs [] ={ 0, 1, 1, 2, 2, 2, 2, 3, 3, 5, 5, 6, 7, 7, 8,};
1427ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1428ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(inputTest, sizeof(inputTest)/sizeof(inputTest[0]),
1429ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                toIBM943, sizeof(toIBM943), "ibm-943",
1430ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset, NULL, 0 ))
1431ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> ibm-943 with substitute did not match.\n");
1432ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1433ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]),
1434ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_euc_jp, sizeof(to_euc_jp), "euc-jp",
1435ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SUBSTITUTE, fromEUC_JPOffs, NULL, 0 ))
1436ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> euc-jp with substitute did not match.\n");
1437ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1438ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(euc_tw_inputText, sizeof(euc_tw_inputText)/sizeof(euc_tw_inputText[0]),
1439ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_euc_tw, sizeof(to_euc_tw), "euc-tw",
1440ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SUBSTITUTE, from_euc_twOffs, NULL, 0 ))
1441ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> euc-tw with substitute did not match.\n");
1442ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1443ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
1444ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1445ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing fromUnicode for SCSU with UCNV_FROM_U_CALLBACK_SUBSTITUTE \n");
1446ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1447ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar SCSU_inputText[]={ 0x0041, 0xd801/*illegal*/, 0x0042, };
1448ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1449ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const uint8_t to_SCSU[]={
1450ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
1451ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0e, 0xff,0xfd,
1452ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42
1453ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1454ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1455ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1456ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t from_SCSUOffs [] ={
1457ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,
1458ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,
1459ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            2,
1460ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1461ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1462ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const uint8_t to_SCSU_1[]={
1463ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
1464ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1465ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1466ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t from_SCSUOffs_1 [] ={
1467ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,
1468ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1469ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1470ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(SCSU_inputText, sizeof(SCSU_inputText)/sizeof(SCSU_inputText[0]),
1471ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_SCSU, sizeof(to_SCSU), "SCSU",
1472ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SUBSTITUTE, from_SCSUOffs, NULL, 0 ))
1473ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> SCSU with substitute did not match.\n");
1474ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1475ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicodeWithContext(SCSU_inputText, sizeof(SCSU_inputText)/sizeof(SCSU_inputText[0]),
1476ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_SCSU_1, sizeof(to_SCSU_1), "SCSU",
1477ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SUBSTITUTE, from_SCSUOffs_1, NULL, 0,"i",U_ILLEGAL_CHAR_FOUND ))
1478ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> SCSU with substitute did not match.\n");
1479ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1480ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1481ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing fromUnicode for UTF-8 with UCNV_FROM_U_CALLBACK_SUBSTITUTE\n");
1482ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1483ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar testinput[]={ 0x20ac, 0xd801, 0xdc01, 0xdc01, 0xd801, 0xffff, 0x0061,};
1484ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t expectedUTF8[]= { 0xe2, 0x82, 0xac,
1485ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                           0xf0, 0x90, 0x90, 0x81,
1486ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                           0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd,
1487ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                           0xef, 0xbf, 0xbf, 0x61,
1488ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1489ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1490ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offsets[]={ 0, 0, 0, 1, 1, 1, 1, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6 };
1491ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(testinput, sizeof(testinput)/sizeof(testinput[0]),
1492ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                expectedUTF8, sizeof(expectedUTF8), "utf8",
1493ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_SUBSTITUTE, offsets, NULL, 0 )) {
1494ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> utf8 with stop did not match.\n");
1495ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1496ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1497ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1498ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing fromUnicode for UTF-16 with UCNV_FROM_U_CALLBACK_SUBSTITUTE\n");
1499ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1500ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar in[]={ 0x0041, 0xfeff };
1501ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1502ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t out[]={
1503ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if U_IS_BIG_ENDIAN
1504ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xfe, 0xff,
1505ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x00, 0x41,
1506ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xfe, 0xff
1507ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#else
1508ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xff, 0xfe,
1509ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41, 0x00,
1510ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xff, 0xfe
1511ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
1512ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1513ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offsets[]={
1514ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            -1, -1, 0, 0, 1, 1
1515ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1516ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1517ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(in, ARRAY_LENGTH(in),
1518ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   out, sizeof(out), "UTF-16",
1519ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   UCNV_FROM_U_CALLBACK_SUBSTITUTE, offsets, NULL, 0)
1520ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1521ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u->UTF-16 with substitute did not match.\n");
1522ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1523ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1524ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1525ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing fromUnicode for UTF-32 with UCNV_FROM_U_CALLBACK_SUBSTITUTE\n");
1526ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1527ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar in[]={ 0x0041, 0xfeff };
1528ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1529ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t out[]={
1530ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if U_IS_BIG_ENDIAN
1531ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x00, 0x00, 0xfe, 0xff,
1532ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x00, 0x00, 0x00, 0x41,
1533ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x00, 0x00, 0xfe, 0xff
1534ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#else
1535ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xff, 0xfe, 0x00, 0x00,
1536ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41, 0x00, 0x00, 0x00,
1537ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xff, 0xfe, 0x00, 0x00
1538ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
1539ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1540ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offsets[]={
1541ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            -1, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 1
1542ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1543ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1544ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(in, ARRAY_LENGTH(in),
1545ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   out, sizeof(out), "UTF-32",
1546ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   UCNV_FROM_U_CALLBACK_SUBSTITUTE, offsets, NULL, 0)
1547ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1548ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u->UTF-32 with substitute did not match.\n");
1549ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1550ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1551ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1552ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*to unicode*/
1553ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1554ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
1555ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertToUnicode(expsubIBM_949, sizeof(expsubIBM_949),
1556ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             IBM_949subtoUnicode, sizeof(IBM_949subtoUnicode)/sizeof(IBM_949subtoUnicode[0]),"ibm-949",
1557ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM949Offs, NULL, 0 ))
1558ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("ibm-949->u with substitute did not match.\n");
1559ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertToUnicode(expsubIBM_943, sizeof(expsubIBM_943),
1560ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             IBM_943subtoUnicode, sizeof(IBM_943subtoUnicode)/sizeof(IBM_943subtoUnicode[0]),"ibm-943",
1561ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM943Offs, NULL, 0 ))
1562ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("ibm-943->u with substitute did not match.\n");
1563ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertToUnicode(expsubIBM_930, sizeof(expsubIBM_930),
1564ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             IBM_930subtoUnicode, sizeof(IBM_930subtoUnicode)/sizeof(IBM_930subtoUnicode[0]),"ibm-930",
1565ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM930Offs, NULL, 0 ))
1566ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("ibm-930->u with substitute did not match.\n");
1567ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1568ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_SUBSTITUTE \n");
1569ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1570ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1571ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const uint8_t sampleTxtEBCIDIC_STATEFUL [] ={
1572ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0e, 0x5d, 0x5f , 0x41, 0x79, 0x41, 0x44
1573ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1574ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar EBCIDIC_STATEFUL_toUnicode[] ={  0x6d63, 0xfffd, 0x03b4
1575ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1576ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t from_EBCIDIC_STATEFULOffsets []={ 1, 3, 5};
1577ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1578ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1579ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* EUC_JP*/
1580ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const uint8_t sampleTxt_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae,
158185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* BEGIN android-changed */
158285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* Android uses a different EUC-JP table. We change this byte sequence,
158385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho             * choosing one that is unassigned in both tables. */
158485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            0x8f, 0xa1, 0xa1,  /*unassigned*/
158585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* 0x8f, 0xda, 0xa1, */ /*unassigned*/
158685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* END android-changed */
1587ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru           0x8e, 0xe0, 0x8a
1588ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1589ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar euc_jptoUnicode[]={ 0x0061, 0x4edd, 0x5bec, 0xfffd, 0x00a2, 0x008a };
1590ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t from_euc_jpOffs [] ={ 0, 1, 3, 6,  9, 11 };
1591ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1592ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*EUC_TW*/
1593ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const uint8_t sampleTxt_euc_tw[]={
1594ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5,
1595ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x8e, 0xaa, 0xbb, 0xcc,/*unassigned*/
1596ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xe6, 0xca, 0x8a,
1597ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1598ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar euc_twtoUnicode[]={ 0x0061, 0x2295, 0x5BF2, 0xfffd, 0x8706, 0x8a, };
1599ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t from_euc_twOffs [] ={ 0, 1, 3, 7, 11, 13};
1600ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1601ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1602ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxtEBCIDIC_STATEFUL, sizeof(sampleTxtEBCIDIC_STATEFUL),
1603ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru           EBCIDIC_STATEFUL_toUnicode, sizeof(EBCIDIC_STATEFUL_toUnicode)/sizeof(EBCIDIC_STATEFUL_toUnicode[0]),"ibm-930",
1604ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          UCNV_TO_U_CALLBACK_SUBSTITUTE, from_EBCIDIC_STATEFULOffsets, NULL, 0 ))
1605ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("EBCIDIC_STATEFUL->u with substitute did not match.\n");
1606ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1607ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1608ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp),
1609ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru           euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp",
1610ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          UCNV_TO_U_CALLBACK_SUBSTITUTE, from_euc_jpOffs, NULL, 0 ))
1611ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("euc-jp->u with substitute did not match.\n");
1612ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1613ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1614ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_euc_tw, sizeof(sampleTxt_euc_tw),
1615ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru           euc_twtoUnicode, sizeof(euc_twtoUnicode)/sizeof(euc_twtoUnicode[0]),"euc-tw",
1616ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          UCNV_TO_U_CALLBACK_SUBSTITUTE, from_euc_twOffs, NULL, 0 ))
1617ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("euc-tw->u with substitute  did not match.\n");
1618ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1619ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1620ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicodeWithContext(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp),
1621ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru           euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp",
1622ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          UCNV_TO_U_CALLBACK_SUBSTITUTE, from_euc_jpOffs, NULL, 0 ,"i", U_ILLEGAL_CHAR_FOUND))
1623ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("euc-jp->u with substitute did not match.\n");
1624ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1625ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
1626ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1627ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing toUnicode for UTF-8 with UCNV_TO_U_CALLBACK_SUBSTITUTE \n");
1628ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1629ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c,
1630ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xe0, 0x80,  0x61,};
1631ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar    expected1[] = {  0x0031, 0x4e8c, 0xfffd, 0x0061};
1632ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t offsets1[] = {   0x0000, 0x0001, 0x0004, 0x0006};
1633ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1634ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleText1, sizeof(sampleText1),
1635ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 expected1, sizeof(expected1)/sizeof(expected1[0]),"utf8",
1636ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets1, NULL, 0 ))
1637ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("utf8->u with substitute did not match.\n");;
1638ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1639ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing toUnicode for SCSU with UCNV_TO_U_CALLBACK_SUBSTITUTE \n");
1640ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1641ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const uint8_t sampleText1[] = {  0xba, 0x8c,0xF8, 0x61,0x0c, 0x0c,};
1642ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar    expected1[] = {  0x00ba,  0x008c,  0x00f8,  0x0061,0xfffd,0xfffd};
1643ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t offsets1[] = {   0x0000, 0x0001,0x0002,0x0003,4,5};
1644ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1645ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleText1, sizeof(sampleText1),
1646ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 expected1, sizeof(expected1)/sizeof(expected1[0]),"SCSU",
1647ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets1, NULL, 0 ))
1648ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("scsu->u with stop did not match.\n");;
1649ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1650ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1651ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
1652ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing ibm-930 subchar/subchar1\n");
1653ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1654ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar u1[]={         0x6d63,           0x6d64,     0x6d65,     0x6d66,     0xdf };
1655ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t s1[]={       0x0e, 0x5d, 0x5f, 0x5d, 0x63, 0xfe, 0xfe, 0x46, 0x6b, 0x0f, 0x3f };
1656ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offsets1[]={ 0,    0,    0,    1,    1,    2,    2,    3,    3,    4,    4 };
1657ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1658ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar u2[]={         0x6d63,           0x6d64,     0xfffd,     0x6d66,     0x1a };
1659ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t s2[]={       0x0e, 0x5d, 0x5f, 0x5d, 0x63, 0xfc, 0xfc, 0x46, 0x6b, 0x0f, 0x57 };
1660ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offsets2[]={ 1,                3,          5,          7,          10 };
1661ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1662ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(u1, ARRAY_LENGTH(u1), s1, ARRAY_LENGTH(s1), "ibm-930",
1663ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                   UCNV_FROM_U_CALLBACK_SUBSTITUTE, offsets1, NULL, 0)
1664ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1665ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u->ibm-930 subchar/subchar1 did not match.\n");
1666ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1667ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1668ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(s2, ARRAY_LENGTH(s2), u2, ARRAY_LENGTH(u2), "ibm-930",
1669ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets2, NULL, 0)
1670ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1671ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("ibm-930->u subchar/subchar1 did not match.\n");
1672ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1673ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1674ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1675ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing GB 18030 with substitute callbacks\n");
1676ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1677ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar u2[]={
1678ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x24, 0x7f, 0x80,                   0x1f9,      0x20ac,     0x4e00,     0x9fa6,                 0xffff,                 0xd800, 0xdc00,         0xfffd,                 0xdbff, 0xdfff };
1679ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t gb2[]={
1680ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x24, 0x7f, 0x81, 0x30, 0x81, 0x30, 0xa8, 0xbf, 0xa2, 0xe3, 0xd2, 0xbb, 0x82, 0x35, 0x8f, 0x33, 0x84, 0x31, 0xa4, 0x39, 0x90, 0x30, 0x81, 0x30, 0xe3, 0x32, 0x9a, 0x36, 0xe3, 0x32, 0x9a, 0x35 };
1681ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offsets2[]={
1682ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0, 1, 2, 6, 8, 10, 12, 16, 20, 20, 24, 28, 28 };
1683ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1684ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(gb2, ARRAY_LENGTH(gb2), u2, ARRAY_LENGTH(u2), "gb18030",
1685ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets2, NULL, 0)
1686ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1687ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("gb18030->u with substitute did not match.\n");
1688ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1689ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1690ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
1691ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1692ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing UTF-7 toUnicode with substitute callbacks\n");
1693ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1694ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t utf7[]={
1695ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru         /* a~            a+AB~                         a+AB\x0c                      a+AB-                         a+AB.                         a+. */
1696ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0x7e,   0x61, 0x2b, 0x41, 0x42, 0x7e, 0x61, 0x2b, 0x41, 0x42, 0x0c, 0x61, 0x2b, 0x41, 0x42, 0x2d, 0x61, 0x2b, 0x41, 0x42, 0x2e, 0x61, 0x2b, 0x2e
1697ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1698ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar unicode[]={
1699ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0xfffd, 0x61,       0xfffd,           0x61,       0xfffd,           0x61,       0xfffd,           0x61,       0xfffd,           0x61, 0xfffd
1700ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1701ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offsets[]={
1702ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,    1,      2,          4,                7,          9,                12,         14,               17,         19,               22,   23
1703ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1704ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1705ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(utf7, ARRAY_LENGTH(utf7), unicode, ARRAY_LENGTH(unicode), "UTF-7",
1706ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets, NULL, 0)
1707ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1708ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("UTF-7->u with substitute did not match.\n");
1709ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1710ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1711ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1712ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing UTF-16 toUnicode with substitute callbacks\n");
1713ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1714ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t
1715ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            in1[]={ 0xfe, 0xff, 0x4e, 0x00, 0xfe, 0xff },
1716ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            in2[]={ 0xff, 0xfe, 0x4e, 0x00, 0xfe, 0xff },
1717ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            in3[]={ 0xfe, 0xfd, 0x4e, 0x00, 0xfe, 0xff };
1718ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1719ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar
1720ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            out1[]={ 0x4e00, 0xfeff },
1721ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            out2[]={ 0x004e, 0xfffe },
1722ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            out3[]={ 0xfefd, 0x4e00, 0xfeff };
1723ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1724ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t
1725ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            offsets1[]={ 2, 4 },
1726ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            offsets2[]={ 2, 4 },
1727ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            offsets3[]={ 0, 2, 4 };
1728ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1729ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(in1, ARRAY_LENGTH(in1), out1, ARRAY_LENGTH(out1), "UTF-16",
1730ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets1, NULL, 0)
1731ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1732ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("UTF-16 (BE BOM)->u with substitute did not match.\n");
1733ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1734ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1735ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(in2, ARRAY_LENGTH(in2), out2, ARRAY_LENGTH(out2), "UTF-16",
1736ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets2, NULL, 0)
1737ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1738ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("UTF-16 (LE BOM)->u with substitute did not match.\n");
1739ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1740ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1741ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(in3, ARRAY_LENGTH(in3), out3, ARRAY_LENGTH(out3), "UTF-16",
1742ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets3, NULL, 0)
1743ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1744ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("UTF-16 (no BOM)->u with substitute did not match.\n");
1745ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1746ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1747ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1748ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing UTF-32 toUnicode with substitute callbacks\n");
1749ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1750ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t
1751ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            in1[]={ 0x00, 0x00, 0xfe, 0xff,   0x00, 0x10, 0x0f, 0x00,   0x00, 0x00, 0xfe, 0xff },
1752ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            in2[]={ 0xff, 0xfe, 0x00, 0x00,   0x00, 0x10, 0x0f, 0x00,   0xfe, 0xff, 0x00, 0x00 },
1753ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            in3[]={ 0x00, 0x00, 0xfe, 0xfe,   0x00, 0x10, 0x0f, 0x00,   0x00, 0x00, 0xd8, 0x40,   0x00, 0x00, 0xdc, 0x01 },
1754ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            in4[]={ 0x00, 0x01, 0x02, 0x03,   0x00, 0x11, 0x12, 0x00,   0x00, 0x00, 0x4e, 0x00 };
1755ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1756ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar
1757ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            out1[]={ UTF16_LEAD(0x100f00), UTF16_TRAIL(0x100f00), 0xfeff },
1758ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            out2[]={ UTF16_LEAD(0x0f1000), UTF16_TRAIL(0x0f1000), 0xfffe },
1759ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            out3[]={ 0xfefe, UTF16_LEAD(0x100f00), UTF16_TRAIL(0x100f00), 0xfffd, 0xfffd },
1760ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            out4[]={ UTF16_LEAD(0x10203), UTF16_TRAIL(0x10203), 0xfffd, 0x4e00 };
1761ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1762ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t
1763ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            offsets1[]={ 4, 4, 8 },
1764ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            offsets2[]={ 4, 4, 8 },
1765ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            offsets3[]={ 0, 4, 4, 8, 12 },
1766ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            offsets4[]={ 0, 0, 4, 8 };
1767ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1768ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(in1, ARRAY_LENGTH(in1), out1, ARRAY_LENGTH(out1), "UTF-32",
1769ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets1, NULL, 0)
1770ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1771ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("UTF-32 (BE BOM)->u with substitute did not match.\n");
1772ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1773ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1774ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(in2, ARRAY_LENGTH(in2), out2, ARRAY_LENGTH(out2), "UTF-32",
1775ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets2, NULL, 0)
1776ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1777ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("UTF-32 (LE BOM)->u with substitute did not match.\n");
1778ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1779ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1780ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(in3, ARRAY_LENGTH(in3), out3, ARRAY_LENGTH(out3), "UTF-32",
1781ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets3, NULL, 0)
1782ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1783ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("UTF-32 (no BOM)->u with substitute did not match.\n");
1784ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1785ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1786ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(in4, ARRAY_LENGTH(in4), out4, ARRAY_LENGTH(out4), "UTF-32",
1787ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                 UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets4, NULL, 0)
1788ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ) {
1789ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("UTF-32 (no BOM, with error)->u with substitute did not match.\n");
1790ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
1791ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
1792ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
1793ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1794ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestSubWithValue(int32_t inputsize, int32_t outputsize)
1795ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
1796ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UChar   sampleText[] =  { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 };
1797ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UChar  sampleText2[] =  { 0x6D63, 0x6D64, 0x6D65, 0x6D66 };
1798ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1799ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const uint8_t expsubwvalIBM_949[]= {
1800ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x00, 0xb0, 0xa1, 0xb0, 0xa2,
1801ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x25, 0x55, 0x45, 0x46, 0x36, 0x37, 0xc8, 0xd3 };
1802ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1803ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const uint8_t expsubwvalIBM_943[]= {
1804ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x9f, 0xaf, 0x9f, 0xb1,
1805ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x25, 0x55, 0x36, 0x44, 0x36, 0x35, 0x89, 0x59 };
1806ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1807ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const uint8_t expsubwvalIBM_930[] = {
1808ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x0e, 0x5d, 0x5f, 0x5d, 0x63, 0x0f, 0x6c, 0xe4, 0xf6, 0xc4, 0xf6, 0xf5, 0x0e, 0x46, 0x6b, 0x0f };
1809ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1810ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t toIBM949Offs [] ={ 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4 };
1811ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t toIBM943Offs [] = { 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3 };
1812ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t toIBM930Offs [] = { 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3 }; /* last item: 3,3,3,3 because there's SO+DBCS+SI */
1813ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1814ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gInBufferSize = inputsize;
1815ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gOutBufferSize = outputsize;
1816ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1817ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*from Unicode*/
1818ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1819ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
1820ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
1821ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            expsubwvalIBM_949, sizeof(expsubwvalIBM_949), "ibm-949",
1822ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_FROM_U_CALLBACK_ESCAPE, toIBM949Offs, NULL, 0 ))
1823ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("u-> ibm-949 with subst with value did not match.\n");
1824ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1825ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
1826ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            expsubwvalIBM_943, sizeof(expsubwvalIBM_943), "ibm-943",
1827ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_FROM_U_CALLBACK_ESCAPE, toIBM943Offs, NULL, 0 ))
1828ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("u-> ibm-943 with sub with value did not match.\n");
1829ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1830ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
1831ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            expsubwvalIBM_930, sizeof(expsubwvalIBM_930), "ibm-930",
1832ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_FROM_U_CALLBACK_ESCAPE, toIBM930Offs, NULL, 0 ))
1833ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("u-> ibm-930 with subst with value did not match.\n");
1834ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1835ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1836ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_ESCAPE  \n");
1837ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
1838ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 };
1839ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t toIBM943[]= { 0x61,
1840ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25, 0x55, 0x44, 0x38, 0x30, 0x31,
1841ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25, 0x55, 0x44, 0x43, 0x30, 0x31,
1842ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25, 0x55, 0x44, 0x38, 0x30, 0x31,
1843ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61 };
1844ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t offset[]= {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 4};
1845ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1846ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1847ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru         /* EUC_JP*/
1848ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar euc_jp_inputText[]={ 0x0061, 0x4edd, 0x5bec, 0xd801, 0xdc01, 0xd801, 0x0061, 0x00a2, };
1849ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae,
1850ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25, 0x55, 0x44, 0x38, 0x30, 0x31,
1851ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25, 0x55, 0x44, 0x43, 0x30, 0x31,
1852ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25, 0x55, 0x44, 0x38, 0x30, 0x31,
1853ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0x8e, 0xe0,
1854ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1855ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t fromEUC_JPOffs [] ={ 0, 1, 1, 2, 2, 2,
1856ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3, 3, 3, 3, 3, 3,
1857ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3, 3, 3, 3, 3, 3,
1858ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            5, 5, 5, 5, 5, 5,
1859ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            6, 7, 7,
1860ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1861ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1862ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*EUC_TW*/
1863ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar euc_tw_inputText[]={ 0x0061, 0x2295, 0x5BF2, 0xd801, 0xdc01, 0xd801, 0x0061, 0x8706, 0x8a, };
1864ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_euc_tw[]={
1865ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5,
1866ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25, 0x55, 0x44, 0x38, 0x30, 0x31,
1867ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25, 0x55, 0x44, 0x43, 0x30, 0x31,
1868ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25, 0x55, 0x44, 0x38, 0x30, 0x31,
1869ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0xe6, 0xca, 0x8a,
1870ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1871ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_euc_twOffs [] ={ 0, 1, 1, 2, 2, 2, 2,
1872ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5,
1873ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             6, 7, 7, 8,
1874ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1875ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISO-2022-JP*/
1876ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_jp_inputText1[]={ 0x3000, 0x00E9, 0x3001,0x00E9, 0x0042} ;
1877ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_jp1[]={
1878ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1b,   0x24,   0x42,   0x21, 0x21,
1879ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1b,   0x28,   0x42,   0x25, 0x55,   0x30,   0x30,   0x45,   0x39,
1880ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1b,   0x24,   0x42,   0x21, 0x22,
1881ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1b,   0x28,   0x42,   0x25, 0x55,   0x30,   0x30,   0x45,   0x39,
1882ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,
1883ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1884ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1885ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_jpOffs1 [] ={
1886ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,0,0,0,0,
1887ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,1,1,1,1,1,1,
1888ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            2,2,2,2,2,
1889ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3,3,3,3,3,3,3,3,3,
1890ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            4,
1891ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1892ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* surrogate pair*/
1893ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_jp_inputText2[]={ 0x3000, 0xD84D, 0xDC56, 0x3001,0xD84D,0xDC56, 0x0042} ;
1894ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_jp2[]={
1895ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x1b,   0x24,   0x42,   0x21,   0x21,
1896ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x1b,   0x28,   0x42,   0x25,   0x55,   0x44,   0x38,   0x34,   0x44,
1897ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x25,   0x55,   0x44,   0x43,   0x35,   0x36,
1898ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x1b,   0x24,   0x42,   0x21,   0x22,
1899ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x1b,   0x28,   0x42,   0x25,   0x55,   0x44,   0x38,   0x34,   0x44,
1900ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x25,   0x55,   0x44,   0x43,   0x35,   0x36,
1901ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x42,
1902ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                };
1903ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_jpOffs2 [] ={
1904ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,0,0,0,0,
1905ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,1,1,1,1,1,1,
1906ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,1,1,1,
1907ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3,3,3,3,3,
1908ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            4,4,4,4,4,4,4,4,4,
1909ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            4,4,4,4,4,4,
1910ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            6,
1911ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1912ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1913ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISO-2022-cn*/
1914ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_cn_inputText[]={ 0x0041, 0x3712, 0x0042, };
1915ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_cn[]={
1916ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
1917ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25, 0x55,   0x33,   0x37,   0x31,   0x32,
1918ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,
1919ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1920ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_cnOffs [] ={
1921ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,
1922ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,1,1,1,
1923ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            2,
1924ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1925ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1926ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_cn_inputText4[]={ 0x3000, 0xD84D, 0xDC56, 0x3001,0xD84D,0xDC56, 0x0042};
1927ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1928ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_cn4[]={
1929ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x1b,   0x24,   0x29,   0x41,   0x0e,   0x21,   0x21,
1930ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x0f,   0x25,   0x55,   0x44,   0x38,   0x34,   0x44,
1931ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x25,   0x55,   0x44,   0x43,   0x35,   0x36,
1932ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x0e,   0x21,   0x22,
1933ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x0f,   0x25,   0x55,   0x44,   0x38,   0x34,   0x44,
1934ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x25,   0x55,   0x44,   0x43,   0x35,   0x36,
1935ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x42,
1936ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             };
1937ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_cnOffs4 [] ={
1938ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,0,0,0,0,0,0,
1939ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,1,1,1,1,
1940ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,1,1,1,
1941ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3,3,3,
1942ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            4,4,4,4,4,4,4,
1943ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            4,4,4,4,4,4,
1944ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            6
1945ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1946ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1947ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1948ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ISO-2022-kr*/
1949ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_kr_inputText2[]={ 0x0041, 0x03A0,0xD84D, 0xDC56/*unassigned*/,0x03A0, 0x0042,0xD84D, 0xDC56/*unassigned*/,0x43 };
1950ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_kr2[]={
1951ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1b,   0x24,   0x29,   0x43,
1952ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
1953ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0e,   0x25,   0x50,
1954ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0f,   0x25,   0x55,   0x44,   0x38,   0x34,   0x44,
1955ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,   0x55,   0x44,   0x43,   0x35,   0x36,
1956ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0e,   0x25,   0x50,
1957ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0f,   0x42,
1958ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,   0x55,   0x44,   0x38,   0x34,   0x44,
1959ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,   0x55,   0x44,   0x43,   0x35,   0x36,
1960ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x43
1961ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1962ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_krOffs2 [] ={
1963ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            -1,-1,-1,-1,
1964ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             0,
1965ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,
1966ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            2,2,2,2,2,2,2,
1967ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            2,2,2,2,2,2,
1968ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            4,4,4,
1969ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            5,5,
1970ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            6,6,6,6,6,6,
1971ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            6,6,6,6,6,6,
1972ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            8,
1973ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1974ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1975ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_kr_inputText[]={ 0x0041, 0x03A0,0x3712/*unassigned*/,0x03A0, 0x0042,0x3712/*unassigned*/,0x43 };
1976ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iso_2022_kr[]={
1977ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1b,   0x24,   0x29,   0x43,
1978ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
1979ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0e,   0x25,   0x50,
1980ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0f,   0x25,   0x55,   0x33,   0x37,   0x31,   0x32,  /*unassigned*/
1981ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0e,   0x25,   0x50,
1982ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0f,   0x42,
1983ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,   0x55,   0x33,   0x37,   0x31,   0x32,  /*unassigned*/
1984ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x43
1985ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1986ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1987ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
1988ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_krOffs [] ={
1989ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            -1,-1,-1,-1,
1990ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             0,
1991ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,
1992ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            2,2,2,2,2,2,2,
1993ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3,3,3,
1994ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            4,4,
1995ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            5,5,5,5,5,5,
1996ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            6,
1997ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
1998ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* HZ encoding */
1999ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar hz_inputText[]={ 0x0041, 0x03A0,0x0662/*unassigned*/,0x03A0, 0x0042, };
2000ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2001ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_hz[]={
2002ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d,   0x41,
2003ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7b,   0x26,   0x30,
2004ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d,   0x25,   0x55,   0x30,   0x36,   0x36,   0x32,  /*unassigned*/
2005ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7b,   0x26,   0x30,
2006ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d,   0x42,
2007ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2008ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2009ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_hzOffs [] ={
2010ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,0,0,
2011ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,1,
2012ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            2,2,2,2,2,2,2,2,
2013ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3,3,3,3,
2014ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            4,4,4
2015ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2016ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2017ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar hz_inputText2[]={ 0x0041, 0x03A0,0xD84D, 0xDC56/*unassigned*/,0x03A0, 0x0042,0xD84D, 0xDC56/*unassigned*/,0x43 };
2018ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_hz2[]={
2019ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d,   0x41,
2020ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7b,   0x26,   0x30,
2021ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d,   0x25,   0x55,   0x44,   0x38,   0x34,   0x44,
2022ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,   0x55,   0x44,   0x43,   0x35,   0x36,
2023ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7b,   0x26,   0x30,
2024ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d,   0x42,
2025ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,   0x55,   0x44,   0x38,   0x34,   0x44,
2026ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,   0x55,   0x44,   0x43,   0x35,   0x36,
2027ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x43
2028ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2029ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_hzOffs2 [] ={
2030ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,0,0,
2031ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,1,
2032ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            2,2,2,2,2,2,2,2,
2033ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            2,2,2,2,2,2,
2034ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            4,4,4,4,
2035ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            5,5,5,
2036ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            6,6,6,6,6,6,
2037ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            6,6,6,6,6,6,
2038ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            8,
2039ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2040ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2041ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                /*ISCII*/
2042ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iscii_inputText[]={ 0x0041, 0x0901,0x3712/*unassigned*/,0x0902, 0x0042,0x3712/*unassigned*/,0x43 };
2043ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t to_iscii[]={
2044ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
2045ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xef,   0x42,   0xa1,
2046ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,   0x55,   0x33,   0x37,   0x31,   0x32,  /*unassigned*/
2047ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xa2,
2048ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,
2049ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,   0x55,   0x33,   0x37,   0x31,   0x32,  /*unassigned*/
2050ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x43
2051ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2052ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2053ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2054ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_isciiOffs [] ={
2055ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0,
2056ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            1,1,1,
2057ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            2,2,2,2,2,2,
2058ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3,
2059ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            4,
2060ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            5,5,5,5,5,5,
2061ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            6,
2062ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2063ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2064ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(inputTest, sizeof(inputTest)/sizeof(inputTest[0]),
2065ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                toIBM943, sizeof(toIBM943), "ibm-943",
2066ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, offset, NULL, 0 ))
2067ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> ibm-943 with subst with value did not match.\n");
2068ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2069ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]),
2070ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_euc_jp, sizeof(to_euc_jp), "euc-jp",
2071ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, fromEUC_JPOffs, NULL, 0 ))
2072ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> euc-jp with subst with value did not match.\n");
2073ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2074ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(euc_tw_inputText, sizeof(euc_tw_inputText)/sizeof(euc_tw_inputText[0]),
2075ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_euc_tw, sizeof(to_euc_tw), "euc-tw",
2076ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_euc_twOffs, NULL, 0 ))
2077ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> euc-tw with subst with value did not match.\n");
2078ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2079ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_jp_inputText1, sizeof(iso_2022_jp_inputText1)/sizeof(iso_2022_jp_inputText1[0]),
2080ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_jp1, sizeof(to_iso_2022_jp1), "iso-2022-jp",
2081ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_jpOffs1, NULL, 0 ))
2082ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso_2022_jp with subst with value did not match.\n");
2083ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2084ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_jp_inputText1, sizeof(iso_2022_jp_inputText1)/sizeof(iso_2022_jp_inputText1[0]),
2085ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_jp1, sizeof(to_iso_2022_jp1), "iso-2022-jp",
2086ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_jpOffs1, NULL, 0 ))
2087ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso_2022_jp with subst with value did not match.\n");
2088ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2089ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_jp_inputText2, sizeof(iso_2022_jp_inputText2)/sizeof(iso_2022_jp_inputText2[0]),
2090ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_jp2, sizeof(to_iso_2022_jp2), "iso-2022-jp",
2091ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_jpOffs2, NULL, 0 ))
2092ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso_2022_jp with subst with value did not match.\n");
2093ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*ESCAPE OPTIONS*/
2094ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
2095ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            /* surrogate pair*/
2096ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const UChar iso_2022_jp_inputText3[]={ 0x3000, 0xD84D, 0xDC56, 0x3001,0xD84D,0xDC56, 0x0042,0x0901c } ;
2097ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const uint8_t to_iso_2022_jp3_v2[]={
2098ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    0x1b,   0x24,   0x42,   0x21,   0x21,
2099ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    0x1b,   0x28,   0x42,   0x26,   0x23,   0x31,  0x34,   0x34,   0x34,   0x37, 0x30, 0x3b,
2100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    0x1b,   0x24,   0x42,   0x21,   0x22,
2102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    0x1b,   0x28,   0x42,   0x26,   0x23,  0x31,  0x34,   0x34,   0x34,   0x37, 0x30, 0x3b,
2103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    0x42,
2105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    0x26,   0x23,   0x33,   0x36,   0x38,   0x39,   0x32,   0x3b,
2106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    };
2107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const int32_t from_iso_2022_jpOffs3_v2 [] ={
2109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                0,0,0,0,0,
2110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                1,1,1,1,1,1,1,1,1,1,1,1,
2111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                3,3,3,3,3,
2113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                4,4,4,4,4,4,4,4,4,4,4,4,
2114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                6,
2116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                7,7,7,7,7,7,7,7,7
2117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            };
2118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            if(!testConvertFromUnicodeWithContext(iso_2022_jp_inputText3, sizeof(iso_2022_jp_inputText3)/sizeof(iso_2022_jp_inputText3[0]),
2120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    to_iso_2022_jp3_v2, sizeof(to_iso_2022_jp3_v2), "iso-2022-jp",
2121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_jpOffs3_v2, NULL, 0,UCNV_ESCAPE_XML_DEC,U_ZERO_ERROR ))
2122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("u-> iso-2022-jp with sub & UCNV_ESCAPE_XML_DEC did not match.\n");
2123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
2125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const UChar iso_2022_cn_inputText5[]={ 0x3000, 0xD84D, 0xDC56, 0x3001,0xD84D,0xDC56, 0x0042,0x0902};
2126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const uint8_t to_iso_2022_cn5_v2[]={
2127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x1b,   0x24,   0x29,   0x41,   0x0e,   0x21,   0x21,
2128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x0f,   0x5c,   0x75,   0x44,   0x38,   0x34,   0x44,
2129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x5c,   0x75,   0x44,   0x43,   0x35,   0x36,
2130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x0e,   0x21,   0x22,
2131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x0f,   0x5c,   0x75,   0x44,   0x38,   0x34,   0x44,
2132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x5c,   0x75,   0x44,   0x43,   0x35,   0x36,
2133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x42,
2134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             0x5c,   0x75,   0x30,   0x39,   0x30,   0x32,
2135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             };
2136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const int32_t from_iso_2022_cnOffs5_v2 [] ={
2137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                0,0,0,0,0,0,0,
2138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                1,1,1,1,1,1,1,
2139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                1,1,1,1,1,1,
2140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                3,3,3,
2141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                4,4,4,4,4,4,4,
2142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                4,4,4,4,4,4,
2143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                6,
2144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                7,7,7,7,7,7
2145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            };
2146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            if(!testConvertFromUnicodeWithContext(iso_2022_cn_inputText5, sizeof(iso_2022_cn_inputText5)/sizeof(iso_2022_cn_inputText5[0]),
2147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_cn5_v2, sizeof(to_iso_2022_cn5_v2), "iso-2022-cn",
2148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_cnOffs5_v2, NULL, 0,UCNV_ESCAPE_JAVA,U_ZERO_ERROR ))
2149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("u-> iso-2022-cn with sub & UCNV_ESCAPE_JAVA did not match.\n");
2150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
2153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const UChar iso_2022_cn_inputText6[]={ 0x3000, 0xD84D, 0xDC56, 0x3001,0xD84D,0xDC56, 0x0042,0x0902};
2154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const uint8_t to_iso_2022_cn6_v2[]={
2155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x1b,   0x24,   0x29,   0x41,   0x0e,   0x21,   0x21,
2156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x0f,   0x7b,   0x55,   0x2b,   0x32,   0x33,   0x34,   0x35,   0x36,   0x7d,
2157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x0e,   0x21,   0x22,
2158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x0f,   0x7b,   0x55,   0x2b,   0x32,   0x33,   0x34,   0x35,   0x36,   0x7d,
2159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x42,
2160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x7b,   0x55,   0x2b,   0x30,   0x39,   0x30,   0x32,   0x7d
2161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             };
2162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const int32_t from_iso_2022_cnOffs6_v2 [] ={
2163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    0,  0,  0,  0,  0,  0,  0,
2164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
2165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    3,  3,  3,
2166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
2167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    6,
2168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    7,  7,  7,  7,  7,  7,  7,  7,
2169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            };
2170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            if(!testConvertFromUnicodeWithContext(iso_2022_cn_inputText6, sizeof(iso_2022_cn_inputText6)/sizeof(iso_2022_cn_inputText6[0]),
2171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_cn6_v2, sizeof(to_iso_2022_cn6_v2), "iso-2022-cn",
2172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_cnOffs6_v2, NULL, 0,UCNV_ESCAPE_UNICODE,U_ZERO_ERROR ))
2173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("u-> iso-2022-cn with sub & UCNV_ESCAPE_UNICODE did not match.\n");
2174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
2177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const UChar iso_2022_cn_inputText7[]={ 0x3000, 0xD84D, 0xDC56, 0x3001,0xD84D,0xDC56, 0x0042,0x0902};
2178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const uint8_t to_iso_2022_cn7_v2[]={
2179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x1b,   0x24,   0x29,   0x41,   0x0e,   0x21,   0x21,
2180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x0f,   0x25,   0x55,   0x44,   0x38,   0x34,   0x44,   0x25,   0x55,   0x44,   0x43,   0x35,   0x36,
2181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x0e,   0x21,   0x22,
2182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x0f,   0x25,   0x55,   0x44,   0x38,   0x34,   0x44,   0x25,   0x55,   0x44,   0x43,   0x35,   0x36,
2183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0x42,   0x25,   0x55,   0x30,   0x39,   0x30,   0x32,
2184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                            };
2185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const int32_t from_iso_2022_cnOffs7_v2 [] ={
2186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                0,  0,  0,  0,  0,  0,  0,
2187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
2188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                3,  3,  3,
2189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
2190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                6,
2191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                7,  7,  7,  7,  7,  7,
2192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            };
2193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            if(!testConvertFromUnicodeWithContext(iso_2022_cn_inputText7, sizeof(iso_2022_cn_inputText7)/sizeof(iso_2022_cn_inputText7[0]),
2194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_cn7_v2, sizeof(to_iso_2022_cn7_v2), "iso-2022-cn",
2195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_cnOffs7_v2, NULL, 0,"K" ,U_ZERO_ERROR ))
2196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("u-> iso-2022-cn with sub & K did not match.\n");
2197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
220085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            static const UChar iso_2022_cn_inputText8[]={
220185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0x3000,
220285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0xD84D, 0xDC56,
220385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0x3001,
220485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0xD84D, 0xDC56,
220585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0xDBFF, 0xDFFF,
220685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0x0042,
220785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0x0902};
220885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            static const uint8_t to_iso_2022_cn8_v2[]={
220985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0x1b,   0x24,   0x29,   0x41,   0x0e,   0x21,   0x21,
221085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0x0f,   0x5c,   0x32,   0x33,   0x34,   0x35,   0x36,   0x20,
221185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0x0e,   0x21,   0x22,
221285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0x0f,   0x5c,   0x32,   0x33,   0x34,   0x35,   0x36,   0x20,
221385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0x5c,   0x31,   0x30,   0x46,   0x46,   0x46,   0x46,   0x20,
221485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0x42,
221585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                                0x5c,   0x39,   0x30,   0x32,   0x20
221685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                             };
221785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            static const int32_t from_iso_2022_cnOffs8_v2 [] ={
221885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                    0,  0,  0,  0,  0,  0,  0,
221985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                    1,  1,  1,  1,  1,  1,  1,  1,
222085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                    3,  3,  3,
222185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                    4,  4,  4,  4,  4,  4,  4,  4,
222285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                    6,  6,  6,  6,  6,  6,  6,  6,
222385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                    8,
222485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                    9,  9,  9,  9,  9
222585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            };
222685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            if(!testConvertFromUnicodeWithContext(iso_2022_cn_inputText8, sizeof(iso_2022_cn_inputText8)/sizeof(iso_2022_cn_inputText8[0]),
222785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                to_iso_2022_cn8_v2, sizeof(to_iso_2022_cn8_v2), "iso-2022-cn",
222885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_cnOffs8_v2, NULL, 0,UCNV_ESCAPE_CSS2,U_ZERO_ERROR ))
222985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                log_err("u-> iso-2022-cn with sub & UCNV_ESCAPE_CSS2 did not match.\n");
223085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho
223185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho        }
223285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho        {
2233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const uint8_t to_iso_2022_cn4_v3[]={
2234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                            0x1b,   0x24,   0x29,   0x41,   0x0e,   0x21,   0x21,
2235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                            0x0f,   0x5c,   0x55,   0x30,   0x30,   0x30,   0x32,   0x33,   0x34,   0x35,   0x36,
2236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                            0x0e,   0x21,   0x22,
2237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                            0x0f,   0x5c,   0x55,   0x30,   0x30,   0x30,   0x32,   0x33,   0x34,   0x35,   0x36,
2238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                            0x42
2239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                             };
2240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            static const int32_t from_iso_2022_cnOffs4_v3 [] ={
2243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                0,0,0,0,0,0,0,
2244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                1,1,1,1,1,1,1,1,1,1,1,
2245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                3,3,3,
2247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                4,4,4,4,4,4,4,4,4,4,4,
2248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                6
2250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            };
2252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            if(!testConvertFromUnicodeWithContext(iso_2022_cn_inputText4, sizeof(iso_2022_cn_inputText4)/sizeof(iso_2022_cn_inputText4[0]),
2253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_cn4_v3, sizeof(to_iso_2022_cn4_v3), "iso-2022-cn",
2254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_cnOffs4_v3, NULL, 0,UCNV_ESCAPE_C,U_ZERO_ERROR ))
2255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            {
2256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("u-> iso-2022-cn with skip & UCNV_ESCAPE_C did not match.\n");
2257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            }
2258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_cn_inputText, sizeof(iso_2022_cn_inputText)/sizeof(iso_2022_cn_inputText[0]),
2260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_cn, sizeof(to_iso_2022_cn), "iso-2022-cn",
2261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_cnOffs, NULL, 0 ))
2262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso_2022_cn with subst with value did not match.\n");
2263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_cn_inputText4, sizeof(iso_2022_cn_inputText4)/sizeof(iso_2022_cn_inputText4[0]),
2265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_cn4, sizeof(to_iso_2022_cn4), "iso-2022-cn",
2266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_cnOffs4, NULL, 0 ))
2267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso_2022_cn with subst with value did not match.\n");
2268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_kr_inputText, sizeof(iso_2022_kr_inputText)/sizeof(iso_2022_kr_inputText[0]),
2269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_kr, sizeof(to_iso_2022_kr), "iso-2022-kr",
2270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_krOffs, NULL, 0 ))
2271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso_2022_kr with subst with value did not match.\n");
2272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iso_2022_kr_inputText2, sizeof(iso_2022_kr_inputText2)/sizeof(iso_2022_kr_inputText2[0]),
2273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iso_2022_kr2, sizeof(to_iso_2022_kr2), "iso-2022-kr",
2274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_krOffs2, NULL, 0 ))
2275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iso_2022_kr2 with subst with value did not match.\n");
2276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(hz_inputText, sizeof(hz_inputText)/sizeof(hz_inputText[0]),
2277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_hz, sizeof(to_hz), "HZ",
2278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_hzOffs, NULL, 0 ))
2279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> hz with subst with value did not match.\n");
2280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(hz_inputText2, sizeof(hz_inputText2)/sizeof(hz_inputText2[0]),
2281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_hz2, sizeof(to_hz2), "HZ",
2282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_hzOffs2, NULL, 0 ))
2283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> hz with subst with value did not match.\n");
2284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertFromUnicode(iscii_inputText, sizeof(iscii_inputText)/sizeof(iscii_inputText[0]),
2286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                to_iscii, sizeof(to_iscii), "ISCII,version=0",
2287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_FROM_U_CALLBACK_ESCAPE, from_isciiOffs, NULL, 0 ))
2288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> iscii with subst with value did not match.\n");
2289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
2291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_ESCAPE \n");
2293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*to Unicode*/
2294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
2296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxtToU[]= { 0x00, 0x9f, 0xaf,
2297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x81, 0xad, /*unassigned*/
2298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x89, 0xd3 };
2299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar IBM_943toUnicode[] = { 0x0000, 0x6D63,
2300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25, 0x58, 0x38, 0x31, 0x25, 0x58, 0x41, 0x44,
2301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7B87};
2302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t  fromIBM943Offs [] =    { 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 5};
2303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* EUC_JP*/
2305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_EUC_JP[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae,
230685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* BEGIN android-changed */
230785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* Android uses a different EUC-JP table. We change this byte sequence,
230885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho             * choosing one that is unassigned in both tables. */
230985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            0x8f, 0xa1, 0xa1,  /*unassigned*/
231085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* 0x8f, 0xda, 0xa1, */ /*unassigned*/
231185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* END android-changed */
2312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru           0x8e, 0xe0,
2313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar EUC_JPtoUnicode[]={ 0x0061, 0x4edd, 0x5bec,
231585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* BEGIN android-changed */
231685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* Android uses a different EUC-JP table. We change the expected output,
231785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho             * matching the byte sequence modified above. */
231885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            0x25, 0x58, 0x38, 0x46, 0x25, 0x58, 0x41, 0x31, 0x25, 0x58, 0x41, 0x31,
231985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* 0x25, 0x58, 0x38, 0x46, 0x25, 0x58, 0x44, 0x41, 0x25, 0x58, 0x41, 0x31, */
232085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho            /* END android-changed */
2321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x00a2 };
2322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t fromEUC_JPOffs [] ={ 0, 1, 3,
2323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
2324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            9,
2325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*EUC_TW*/
2328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_euc_tw[]={
2329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5,
2330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x8e, 0xaa, 0xbb, 0xcc,/*unassigned*/
2331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xe6, 0xca, 0x8a,
2332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar euc_twtoUnicode[]={ 0x0061, 0x2295, 0x5BF2,
2334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             0x25, 0x58, 0x38, 0x45, 0x25, 0x58, 0x41, 0x41, 0x25, 0x58, 0x42, 0x42, 0x25, 0x58, 0x43, 0x43,
2335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             0x8706, 0x8a, };
2336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_euc_twOffs [] ={ 0, 1, 3,
2337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
2338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             11, 13};
2339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*iso-2022-jp*/
2341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_iso_2022_jp[]={
2342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1b,   0x28,   0x42,   0x41,
2343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1b,   0x24,   0x42,   0x2A, 0x44, /*unassigned*/
2344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1b,   0x28,   0x42,   0x42,
2345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2346ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_jptoUnicode[]={    0x41,0x25,0x58,0x32,0x41,0x25,0x58,0x34,0x34, 0x42 };
2348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_jpOffs [] ={  3,   7,   7,   7,   7,   7,   7,   7,   7,    12   };
2349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*iso-2022-cn*/
2351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_iso_2022_cn[]={
2352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0f,   0x41,   0x44,
2353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x1B,   0x24,   0x29,   0x47,
2354ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0E,   0x40,   0x6c, /*unassigned*/
2355ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0f,   0x42,
2356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_cntoUnicode[]={    0x41, 0x44,0x25,0x58,0x34,0x30,0x25,0x58,0x36,0x43,0x42 };
2359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_cnOffs [] ={  1,   2,   8,   8,   8,   8,   8,   8,   8,  8,    11   };
2360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2361ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*iso-2022-kr*/
2362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_iso_2022_kr[]={
2363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          0x1b, 0x24, 0x29,  0x43,
2364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          0x41,
2365ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          0x0E, 0x7f, 0x1E,
2366ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          0x0e, 0x25, 0x50,
2367ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          0x0f, 0x51,
2368ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru          0x42, 0x43,
2369ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2370ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2371ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar iso_2022_krtoUnicode[]={     0x41,0x25,0x58,0x37,0x46,0x25,0x58,0x31,0x45,0x03A0,0x51, 0x42,0x43};
2372ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_iso_2022_krOffs [] ={  4,   6,   6,   6,   6,   6,   6,   6,   6,    9,    12,   13  , 14 };
2373ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2374ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*hz*/
2375ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_hz[]={
2376ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
2377ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7b,   0x26,   0x30,
2378ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7f,   0x1E, /*unassigned*/
2379ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x26,   0x30,
2380ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d,   0x42,
2381ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7b,   0x7f,   0x1E,/*unassigned*/
2382ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x7e,   0x7d,   0x42,
2383ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2384ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar hztoUnicode[]={
2385ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
2386ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x03a0,
2387ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,0x58,0x37,0x46,0x25,0x58,0x31,0x45,
2388ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x03A0,
2389ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,
2390ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,0x58,0x37,0x46,0x25,0x58,0x31,0x45,
2391ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,};
2392ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2393ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_hzOffs [] ={0,3,5,5,5,5,5,5,5,5,7,11,14,14,14,14,14,14,14,14,18,  };
2394ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2395ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2396ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*iscii*/
2397ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxt_iscii[]={
2398ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
2399ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x30,
2400ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xEB, /*unassigned*/
2401ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xa3,
2402ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,
2403ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xEC, /*unassigned*/
2404ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,
2405ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2406ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar isciitoUnicode[]={
2407ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x41,
2408ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x30,
2409ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,  0x58,  0x45, 0x42,
2410ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0903,
2411ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,
2412ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x25,  0x58,  0x45, 0x43,
2413ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x42,};
2414ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2415ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t from_isciiOffs [] ={0,1,2,2,2,2,3,4,5,5,5,5,6  };
2416ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
2417ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2418ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /*UTF8*/
2419ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const uint8_t sampleTxtUTF8[]={
2420ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20, 0x64, 0x50,
2421ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xC2, 0x7E, /* truncated char */
2422ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x20,
2423ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0xE0, 0xB5, 0x7E, /* truncated char */
2424ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x40,
2425ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2426ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar UTF8ToUnicode[]={
2427ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0020, 0x0064, 0x0050,
2428ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0025, 0x0058, 0x0043, 0x0032, 0x007E,  /* \xC2~ */
2429ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0020,
2430ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0025, 0x0058, 0x0045, 0x0030, 0x0025, 0x0058, 0x0042, 0x0035, 0x007E,
2431ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0040
2432ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2433ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t fromUTF8[] = {
2434ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0, 1, 2,
2435ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3, 3, 3, 3, 4,
2436ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            5,
2437ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            6, 6, 6, 6, 6, 6, 6, 6, 8,
2438ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            9
2439ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2440ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const UChar UTF8ToUnicodeXML_DEC[]={
2441ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0020, 0x0064, 0x0050,
2442ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0026, 0x0023, 0x0031, 0x0039, 0x0034, 0x003B, 0x007E,  /* &#194;~ */
2443ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0020,
2444ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0026, 0x0023, 0x0032, 0x0032, 0x0034, 0x003B, 0x0026, 0x0023, 0x0031, 0x0038, 0x0031, 0x003B, 0x007E,
2445ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0x0040
2446ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2447ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        static const int32_t fromUTF8XML_DEC[] = {
2448ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            0, 1, 2,
2449ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            3, 3, 3, 3, 3, 3, 4,
2450ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            5,
2451ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8,
2452ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            9
2453ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        };
2454ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2455ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2456ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
2457ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxtToU, sizeof(sampleTxtToU),
2458ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 IBM_943toUnicode, sizeof(IBM_943toUnicode)/sizeof(IBM_943toUnicode[0]),"ibm-943",
2459ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_ESCAPE, fromIBM943Offs, NULL, 0 ))
2460ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("ibm-943->u with substitute with value did not match.\n");
2461ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2462ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_EUC_JP, sizeof(sampleTxt_EUC_JP),
2463ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 EUC_JPtoUnicode, sizeof(EUC_JPtoUnicode)/sizeof(EUC_JPtoUnicode[0]),"euc-jp",
2464ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_ESCAPE, fromEUC_JPOffs, NULL, 0))
2465ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("euc-jp->u with substitute with value did not match.\n");
2466ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2467ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_euc_tw, sizeof(sampleTxt_euc_tw),
2468ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 euc_twtoUnicode, sizeof(euc_twtoUnicode)/sizeof(euc_twtoUnicode[0]),"euc-tw",
2469ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_ESCAPE, from_euc_twOffs, NULL, 0))
2470ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("euc-tw->u with substitute with value did not match.\n");
2471ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2472ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_iso_2022_jp, sizeof(sampleTxt_iso_2022_jp),
2473ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 iso_2022_jptoUnicode, sizeof(iso_2022_jptoUnicode)/sizeof(iso_2022_jptoUnicode[0]),"iso-2022-jp",
2474ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_ESCAPE, from_iso_2022_jpOffs, NULL, 0))
2475ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("iso-2022-jp->u with substitute with value did not match.\n");
2476ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2477ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicodeWithContext(sampleTxt_iso_2022_jp, sizeof(sampleTxt_iso_2022_jp),
2478ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 iso_2022_jptoUnicode, sizeof(iso_2022_jptoUnicode)/sizeof(iso_2022_jptoUnicode[0]),"iso-2022-jp",
2479ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_ESCAPE, from_iso_2022_jpOffs, NULL, 0,"K",U_ZERO_ERROR))
2480ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("iso-2022-jp->u with substitute with value did not match.\n");
2481ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2482ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {/* test UCNV_TO_U_CALLBACK_ESCAPE with options */
2483ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            {
2484ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                static const UChar iso_2022_jptoUnicodeDec[]={
2485ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                                  0x0041,
2486ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                                  0x0026,   0x0023,   0x0034,   0x0032,   0x003b,
2487ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                                  0x0026,   0x0023,   0x0036,   0x0038,   0x003b,
2488ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                                  0x0042 };
2489ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                static const int32_t from_iso_2022_jpOffsDec [] ={ 3,7,7,7,7,7,7,7,7,7,7,12,  };
2490ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                if(!testConvertToUnicodeWithContext(sampleTxt_iso_2022_jp, sizeof(sampleTxt_iso_2022_jp),
2491ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                     iso_2022_jptoUnicodeDec, sizeof(iso_2022_jptoUnicodeDec)/sizeof(iso_2022_jptoUnicode[0]),"iso-2022-jp",
2492ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    UCNV_TO_U_CALLBACK_ESCAPE, from_iso_2022_jpOffsDec, NULL, 0,UCNV_ESCAPE_XML_DEC,U_ZERO_ERROR ))
2493ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("iso-2022-jp->u with substitute with value and UCNV_ESCAPE_XML_DEC did not match.\n");
2494ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            }
2495ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            {
2496ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                static const UChar iso_2022_jptoUnicodeHex[]={
2497ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                                  0x0041,
2498ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                                  0x0026, 0x0023, 0x0078, 0x0032, 0x0041, 0x003b,
2499ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                                  0x0026, 0x0023, 0x0078, 0x0034, 0x0034, 0x003b,
2500ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                                  0x0042 };
2501ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                static const int32_t from_iso_2022_jpOffsHex [] ={  3,7,7,7,7,7,7,7,7,7,7,7,7,12   };
2502ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                if(!testConvertToUnicodeWithContext(sampleTxt_iso_2022_jp, sizeof(sampleTxt_iso_2022_jp),
2503ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                     iso_2022_jptoUnicodeHex, sizeof(iso_2022_jptoUnicodeHex)/sizeof(iso_2022_jptoUnicode[0]),"iso-2022-jp",
2504ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    UCNV_TO_U_CALLBACK_ESCAPE, from_iso_2022_jpOffsHex, NULL, 0,UCNV_ESCAPE_XML_HEX,U_ZERO_ERROR ))
2505ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("iso-2022-jp->u with substitute with value and UCNV_ESCAPE_XML_HEX did not match.\n");
2506ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            }
2507ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            {
2508ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                static const UChar iso_2022_jptoUnicodeC[]={
2509ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                                0x0041,
2510ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                                0x005C, 0x0078, 0x0032, 0x0041,
2511ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                                0x005C, 0x0078, 0x0034, 0x0034,
2512ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                                0x0042 };
2513ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                int32_t from_iso_2022_jpOffsC [] ={  3,7,7,7,7,7,7,7,7,12   };
2514ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                if(!testConvertToUnicodeWithContext(sampleTxt_iso_2022_jp, sizeof(sampleTxt_iso_2022_jp),
2515ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                     iso_2022_jptoUnicodeC, sizeof(iso_2022_jptoUnicodeC)/sizeof(iso_2022_jptoUnicode[0]),"iso-2022-jp",
2516ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                    UCNV_TO_U_CALLBACK_ESCAPE, from_iso_2022_jpOffsC, NULL, 0,UCNV_ESCAPE_C,U_ZERO_ERROR ))
2517ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("iso-2022-jp->u with substitute with value and UCNV_ESCAPE_C did not match.\n");
2518ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            }
2519ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2520ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_iso_2022_cn, sizeof(sampleTxt_iso_2022_cn),
2521ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 iso_2022_cntoUnicode, sizeof(iso_2022_cntoUnicode)/sizeof(iso_2022_cntoUnicode[0]),"iso-2022-cn",
2522ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_ESCAPE, from_iso_2022_cnOffs, NULL, 0))
2523ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("iso-2022-cn->u with substitute with value did not match.\n");
2524ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2525ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxt_iso_2022_kr, sizeof(sampleTxt_iso_2022_kr),
2526ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 iso_2022_krtoUnicode, sizeof(iso_2022_krtoUnicode)/sizeof(iso_2022_krtoUnicode[0]),"iso-2022-kr",
2527ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_ESCAPE, from_iso_2022_krOffs, NULL, 0))
2528ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("iso-2022-kr->u with substitute with value did not match.\n");
2529ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2530ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru         if(!testConvertToUnicode(sampleTxt_hz, sizeof(sampleTxt_hz),
2531ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 hztoUnicode, sizeof(hztoUnicode)/sizeof(hztoUnicode[0]),"HZ",
2532ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_ESCAPE, from_hzOffs, NULL, 0))
2533ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("hz->u with substitute with value did not match.\n");
2534ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2535ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru         if(!testConvertToUnicode(sampleTxt_iscii, sizeof(sampleTxt_iscii),
2536ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                 isciitoUnicode, sizeof(isciitoUnicode)/sizeof(isciitoUnicode[0]),"ISCII,version=0",
2537ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_ESCAPE, from_isciiOffs, NULL, 0))
2538ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("ISCII ->u with substitute with value did not match.\n");
2539ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
2540ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2541ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicode(sampleTxtUTF8, sizeof(sampleTxtUTF8),
2542ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UTF8ToUnicode, sizeof(UTF8ToUnicode)/sizeof(UTF8ToUnicode[0]),"UTF-8",
2543ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_ESCAPE, fromUTF8, NULL, 0))
2544ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("UTF8->u with UCNV_TO_U_CALLBACK_ESCAPE with value did not match.\n");
2545ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(!testConvertToUnicodeWithContext(sampleTxtUTF8, sizeof(sampleTxtUTF8),
2546ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UTF8ToUnicodeXML_DEC, sizeof(UTF8ToUnicodeXML_DEC)/sizeof(UTF8ToUnicodeXML_DEC[0]),"UTF-8",
2547ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UCNV_TO_U_CALLBACK_ESCAPE, fromUTF8XML_DEC, NULL, 0, UCNV_ESCAPE_XML_DEC, U_ZERO_ERROR))
2548ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("UTF8->u with UCNV_TO_U_CALLBACK_ESCAPE with value did not match.\n");
2549ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2550ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
2551ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2552ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_LEGACY_CONVERSION
2553ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestLegalAndOthers(int32_t inputsize, int32_t outputsize)
2554ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
2555ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const UChar    legalText[] =  { 0x0000, 0xAC00, 0xAC01, 0xD700 };
2556ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t templegal949[] ={ 0x00, 0xb0, 0xa1, 0xb0, 0xa2, 0xc8, 0xd3 };
2557ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t  to949legal[] = {0, 1, 1, 2, 2, 3, 3};
2558ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2559ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2560ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t text943[] = {
256185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho        0x82, 0xa9, 0x82, 0x20, 0x61, 0x8a, 0xbf, 0x8e, 0x9a };
256285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    static const UChar toUnicode943sub[] = { 0x304b, 0x1a, 0x20, 0x0061, 0x6f22,  0x5b57 };
256385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    static const UChar toUnicode943skip[]= { 0x304b, 0x20, 0x0061, 0x6f22,  0x5b57 };
2564ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const UChar toUnicode943stop[]= { 0x304b};
2565ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
256685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    static const int32_t  fromIBM943Offssub[]  = { 0, 2, 3, 4, 5, 7 };
256785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    static const int32_t  fromIBM943Offsskip[] = { 0, 3, 4, 5, 7 };
2568ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t  fromIBM943Offsstop[] = { 0};
2569ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2570ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gInBufferSize = inputsize;
2571ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gOutBufferSize = outputsize;
2572ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*checking with a legal value*/
2573ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertFromUnicode(legalText, sizeof(legalText)/sizeof(legalText[0]),
2574ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            templegal949, sizeof(templegal949), "ibm-949",
2575ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_FROM_U_CALLBACK_SKIP, to949legal, NULL, 0 ))
2576ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("u-> ibm-949 with skip did not match.\n");
2577ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2578ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*checking illegal value for ibm-943 with substitute*/
2579ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertToUnicode(text943, sizeof(text943),
2580ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             toUnicode943sub, sizeof(toUnicode943sub)/sizeof(toUnicode943sub[0]),"ibm-943",
2581ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM943Offssub, NULL, 0 ))
2582ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("ibm-943->u with subst did not match.\n");
2583ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*checking illegal value for ibm-943 with skip */
2584ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertToUnicode(text943, sizeof(text943),
2585ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             toUnicode943skip, sizeof(toUnicode943skip)/sizeof(toUnicode943skip[0]),"ibm-943",
2586ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_SKIP, fromIBM943Offsskip, NULL, 0 ))
2587ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("ibm-943->u with skip did not match.\n");
2588ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2589ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*checking illegal value for ibm-943 with stop */
2590ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertToUnicode(text943, sizeof(text943),
2591ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             toUnicode943stop, sizeof(toUnicode943stop)/sizeof(toUnicode943stop[0]),"ibm-943",
2592ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_STOP, fromIBM943Offsstop, NULL, 0 ))
2593ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("ibm-943->u with stop did not match.\n");
2594ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2595ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
2596ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2597ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestSingleByte(int32_t inputsize, int32_t outputsize)
2598ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
2599ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t sampleText[] = {
2600ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        0x82, 0xa9, 0x61, 0x62, 0x63 , 0x82,
260185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho        0xff, 0x32, 0x33};
260285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    static const UChar toUnicode943sub[] = { 0x304b, 0x0061, 0x0062, 0x0063, 0x1a, 0x1a, 0x0032, 0x0033 };
260385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    static const int32_t fromIBM943Offssub[] = { 0, 2, 3, 4, 5, 6, 7, 8 };
2604ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*checking illegal value for ibm-943 with substitute*/
2605ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gInBufferSize = inputsize;
2606ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gOutBufferSize = outputsize;
2607ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2608ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertToUnicode(sampleText, sizeof(sampleText),
2609ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru             toUnicode943sub, sizeof(toUnicode943sub)/sizeof(toUnicode943sub[0]),"ibm-943",
2610ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM943Offssub, NULL, 0 ))
2611ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("ibm-943->u with subst did not match.\n");
2612ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
2613ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2614ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestEBCDIC_STATEFUL_Sub(int32_t inputsize, int32_t outputsize)
2615ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
2616ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*EBCDIC_STATEFUL*/
2617ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const UChar ebcdic_inputTest[] = { 0x0061, 0x6d64, 0x0061, 0x00A2, 0x6d65, 0x0061 };
2618ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t toIBM930[]= { 0x62, 0x0e, 0x5d, 0x63, 0x0f, 0x62, 0xb1, 0x0e, 0xfe, 0xfe, 0x0f, 0x62 };
2619ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t offset_930[]=     { 0,    1,    1,    1,    2,    2,    3,    4,    4,    4,    5,    5    };
2620ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*                              s     SO    doubl       SI    sng   s     SO    fe    fe    SI    s    */
2621ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2622ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*EBCDIC_STATEFUL with subChar=3f*/
2623ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const uint8_t toIBM930_subvaried[]= { 0x62, 0x0e, 0x5d, 0x63, 0x0f, 0x62, 0xb1, 0x3f, 0x62 };
2624ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const int32_t offset_930_subvaried[]=     { 0,    1,    1,    1,    2,    2,    3,    4,    5    };
2625ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static const char mySubChar[]={ 0x3f};
2626ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2627ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gInBufferSize = inputsize;
2628ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    gOutBufferSize = outputsize;
2629ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2630ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertFromUnicode(ebcdic_inputTest, sizeof(ebcdic_inputTest)/sizeof(ebcdic_inputTest[0]),
2631ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        toIBM930, sizeof(toIBM930), "ibm-930",
2632ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset_930, NULL, 0 ))
2633ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> ibm-930(EBCDIC_STATEFUL) with subst did not match.\n");
2634ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2635ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!testConvertFromUnicode(ebcdic_inputTest, sizeof(ebcdic_inputTest)/sizeof(ebcdic_inputTest[0]),
2636ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        toIBM930_subvaried, sizeof(toIBM930_subvaried), "ibm-930",
2637ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset_930_subvaried, mySubChar, 1 ))
2638ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("u-> ibm-930(EBCDIC_STATEFUL) with subst(setSubChar=0x3f) did not match.\n");
2639ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
2640ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
2641ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2642ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruUBool testConvertFromUnicode(const UChar *source, int sourceLen,  const uint8_t *expect, int expectLen,
2643ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                const char *codepage, UConverterFromUCallback callback , const int32_t *expectOffsets,
2644ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                const char *mySubChar, int8_t len)
2645ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
2646ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2647ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2648ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
2649ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UConverter *conv = 0;
2650ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char junkout[NEW_MAX_BUFFER]; /* FIX */
2651ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t junokout[NEW_MAX_BUFFER]; /* FIX */
2652ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const UChar *src;
2653ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char *end;
2654ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char *targ;
2655ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t *offs;
2656ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int i;
2657ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t  realBufferSize;
2658ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char *realBufferEnd;
2659ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const UChar *realSourceEnd;
2660ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const UChar *sourceLimit;
2661ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool checkOffsets = TRUE;
2662ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool doFlush;
2663ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char junk[9999];
2664ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char offset_str[9999];
2665ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char *p;
2666ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UConverterFromUCallback oldAction = NULL;
2667ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const void* oldContext = NULL;
2668ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2669ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2670ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    for(i=0;i<NEW_MAX_BUFFER;i++)
2671ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        junkout[i] = (char)0xF0;
2672ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    for(i=0;i<NEW_MAX_BUFFER;i++)
2673ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        junokout[i] = 0xFF;
2674ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    setNuConvTestName(codepage, "FROM");
2675ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2676ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("\nTesting========= %s  FROM \n  inputbuffer= %d   outputbuffer= %d\n", codepage, gInBufferSize,
2677ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            gOutBufferSize);
2678ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2679ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    conv = ucnv_open(codepage, &status);
2680ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(U_FAILURE(status))
2681ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2682ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_data_err("Couldn't open converter %s\n",codepage);
2683ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return TRUE;
2684ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2685ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2686ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Converter opened..\n");
2687ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2688ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*----setting the callback routine----*/
2689ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ucnv_setFromUCallBack (conv, callback, NULL, &oldAction, &oldContext, &status);
2690ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (U_FAILURE(status))
2691ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2692ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("FAILURE in setting the callback Function! %s\n", myErrorName(status));
2693ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2694ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*------------------------*/
2695ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*setting the subChar*/
2696ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(mySubChar != NULL){
2697ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ucnv_setSubstChars(conv, mySubChar, len, &status);
2698ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if (U_FAILURE(status))  {
2699ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("FAILURE in setting the callback Function! %s\n", myErrorName(status));
2700ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2701ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2702ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*------------*/
2703ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2704ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    src = source;
2705ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    targ = junkout;
2706ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    offs = junokout;
2707ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2708ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    realBufferSize = (sizeof(junkout)/sizeof(junkout[0]));
2709ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    realBufferEnd = junkout + realBufferSize;
2710ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    realSourceEnd = source + sourceLen;
2711ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2712ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if ( gOutBufferSize != realBufferSize )
2713ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      checkOffsets = FALSE;
2714ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2715ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if( gInBufferSize != NEW_MAX_BUFFER )
2716ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      checkOffsets = FALSE;
2717ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2718ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    do
2719ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2720ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        end = nct_min(targ + gOutBufferSize, realBufferEnd);
2721ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        sourceLimit = nct_min(src + gInBufferSize, realSourceEnd);
2722ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2723ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        doFlush = (UBool)(sourceLimit == realSourceEnd);
2724ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2725ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(targ == realBufferEnd)
2726ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
2727ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Error, overflowed the real buffer while about to call fromUnicode! targ=%08lx %s", targ, gNuConvTestName);
2728ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            return FALSE;
2729ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2730ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("calling fromUnicode @ SOURCE:%08lx to %08lx  TARGET: %08lx to %08lx, flush=%s\n", src,sourceLimit, targ,end, doFlush?"TRUE":"FALSE");
2731ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2732ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2733ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        status = U_ZERO_ERROR;
2734ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2735ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ucnv_fromUnicode (conv,
2736ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  (char **)&targ,
2737ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  (const char *)end,
2738ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  &src,
2739ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  sourceLimit,
2740ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  checkOffsets ? offs : NULL,
2741ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  doFlush, /* flush if we're at the end of the input data */
2742ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  &status);
2743ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    } while ( (status == U_BUFFER_OVERFLOW_ERROR) || (U_SUCCESS(status) && (sourceLimit < realSourceEnd)) );
2744ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2745ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2746ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(status==U_INVALID_CHAR_FOUND || status == U_ILLEGAL_CHAR_FOUND){
2747ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar errChars[50]; /* should be sufficient */
2748ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int8_t errLen = 50;
2749ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UErrorCode err = U_ZERO_ERROR;
2750ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const UChar* limit= NULL;
2751ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const UChar* start= NULL;
2752ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ucnv_getInvalidUChars(conv,errChars, &errLen, &err);
2753ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(U_FAILURE(err)){
2754ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("ucnv_getInvalidUChars failed with error : %s\n",u_errorName(err));
2755ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2756ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* src points to limit of invalid chars */
2757ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        limit = src;
2758ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* length of in invalid chars should be equal to returned length*/
2759ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        start = src - errLen;
2760ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(u_strncmp(errChars,start,errLen)!=0){
2761ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("ucnv_getInvalidUChars did not return the correct invalid chars for encoding %s \n", ucnv_getName(conv,&err));
2762ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2763ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2764ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /* allow failure codes for the stop callback */
2765ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(U_FAILURE(status) &&
2766ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru       (callback != UCNV_FROM_U_CALLBACK_STOP || (status != U_INVALID_CHAR_FOUND && status != U_ILLEGAL_CHAR_FOUND)))
2767ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2768ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Problem in fromUnicode, errcode %s %s\n", myErrorName(status), gNuConvTestName);
2769ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return FALSE;
2770ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2771ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2772ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("\nConversion done [%d uchars in -> %d chars out]. \nResult :",
2773ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        sourceLen, targ-junkout);
277427f654740f2a26ad62a5c155af9199af9e69b889claireho    if(getTestOption(VERBOSITY_OPTION))
2775ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2776ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2777ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        junk[0] = 0;
2778ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        offset_str[0] = 0;
2779ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        for(p = junkout;p<targ;p++)
2780ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
2781ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            sprintf(junk + strlen(junk), "0x%02x, ", (0xFF) & (unsigned int)*p);
2782ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            sprintf(offset_str + strlen(offset_str), "0x%02x, ", (0xFF) & (unsigned int)junokout[p-junkout]);
2783ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2784ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2785ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose(junk);
2786ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printSeq(expect, expectLen);
2787ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if ( checkOffsets )
2788ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
2789ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_verbose("\nOffsets:");
2790ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_verbose(offset_str);
2791ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2792ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("\n");
2793ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2794ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ucnv_close(conv);
2795ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2796ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2797ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(expectLen != targ-junkout)
2798ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2799ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Expected %d chars out, got %d %s\n", expectLen, targ-junkout, gNuConvTestName);
2800ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("Expected %d chars out, got %d %s\n", expectLen, targ-junkout, gNuConvTestName);
2801ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printSeqErr((const uint8_t *)junkout, (int32_t)(targ-junkout));
2802ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printSeqErr(expect, expectLen);
2803ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return FALSE;
2804ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2805ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2806ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (checkOffsets && (expectOffsets != 0) )
2807ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2808ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("comparing %d offsets..\n", targ-junkout);
2809ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(memcmp(junokout,expectOffsets,(targ-junkout) * sizeof(int32_t) )){
2810ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("did not get the expected offsets while %s \n", gNuConvTestName);
2811ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Got Output : ");
2812ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            printSeqErr((const uint8_t *)junkout, (int32_t)(targ-junkout));
2813ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Got Offsets:      ");
2814ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            for(p=junkout;p<targ;p++)
2815ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("%d,", junokout[p-junkout]);
2816ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("\n");
2817ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Expected Offsets: ");
2818ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            for(i=0; i<(targ-junkout); i++)
2819ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("%d,", expectOffsets[i]);
2820ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("\n");
2821ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            return FALSE;
2822ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2823ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2824ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2825ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!memcmp(junkout, expect, expectLen))
2826ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2827ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("String matches! %s\n", gNuConvTestName);
2828ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return TRUE;
2829ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2830ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    else
2831ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2832ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("String does not match. %s\n", gNuConvTestName);
2833ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("source: ");
2834ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printUSeqErr(source, sourceLen);
2835ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Got:      ");
2836ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printSeqErr((const uint8_t *)junkout, expectLen);
2837ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Expected: ");
2838ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printSeqErr(expect, expectLen);
2839ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return FALSE;
2840ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2841ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
2842ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2843ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruUBool testConvertToUnicode( const uint8_t *source, int sourcelen, const UChar *expect, int expectlen,
2844ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru               const char *codepage, UConverterToUCallback callback, const int32_t *expectOffsets,
2845ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru               const char *mySubChar, int8_t len)
2846ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
2847ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
2848ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UConverter *conv = 0;
2849ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UChar   junkout[NEW_MAX_BUFFER]; /* FIX */
2850ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t junokout[NEW_MAX_BUFFER]; /* FIX */
2851ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const char *src;
2852ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const char *realSourceEnd;
2853ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const char *srcLimit;
2854ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UChar *targ;
2855ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UChar *end;
2856ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t *offs;
2857ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int i;
2858ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool   checkOffsets = TRUE;
2859ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char junk[9999];
2860ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char offset_str[9999];
2861ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UChar *p;
2862ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UConverterToUCallback oldAction = NULL;
2863ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const void* oldContext = NULL;
2864ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2865ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t   realBufferSize;
2866ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UChar *realBufferEnd;
2867ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2868ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2869ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    for(i=0;i<NEW_MAX_BUFFER;i++)
2870ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        junkout[i] = 0xFFFE;
2871ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2872ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    for(i=0;i<NEW_MAX_BUFFER;i++)
2873ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        junokout[i] = -1;
2874ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2875ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    setNuConvTestName(codepage, "TO");
2876ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2877ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("\n=========  %s\n", gNuConvTestName);
2878ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2879ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    conv = ucnv_open(codepage, &status);
2880ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(U_FAILURE(status))
2881ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2882ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_data_err("Couldn't open converter %s\n",gNuConvTestName);
2883ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return TRUE;
2884ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2885ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2886ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Converter opened..\n");
2887ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2888ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    src = (const char *)source;
2889ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    targ = junkout;
2890ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    offs = junokout;
2891ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2892ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    realBufferSize = (sizeof(junkout)/sizeof(junkout[0]));
2893ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    realBufferEnd = junkout + realBufferSize;
2894ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    realSourceEnd = src + sourcelen;
2895ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*----setting the callback routine----*/
2896ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ucnv_setToUCallBack (conv, callback, NULL, &oldAction, &oldContext, &status);
2897ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (U_FAILURE(status))
2898ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2899ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("FAILURE in setting the callback Function! %s\n", myErrorName(status));
2900ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2901ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*-------------------------------------*/
2902ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*setting the subChar*/
2903ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(mySubChar != NULL){
2904ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ucnv_setSubstChars(conv, mySubChar, len, &status);
2905ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if (U_FAILURE(status))  {
2906ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("FAILURE in setting the callback Function! %s\n", myErrorName(status));
2907ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2908ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2909ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*------------*/
2910ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2911ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2912ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if ( gOutBufferSize != realBufferSize )
2913ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        checkOffsets = FALSE;
2914ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2915ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if( gInBufferSize != NEW_MAX_BUFFER )
2916ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        checkOffsets = FALSE;
2917ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2918ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    do
2919ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2920ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        end = nct_min( targ + gOutBufferSize, realBufferEnd);
2921ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        srcLimit = nct_min(realSourceEnd, src + gInBufferSize);
2922ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2923ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(targ == realBufferEnd)
2924ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
2925ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Error, the end would overflow the real output buffer while about to call toUnicode! tarjey=%08lx %s",targ,gNuConvTestName);
2926ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            return FALSE;
2927ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2928ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("calling toUnicode @ %08lx to %08lx\n", targ,end);
2929ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2930ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2931ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2932ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        status = U_ZERO_ERROR;
2933ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2934ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ucnv_toUnicode (conv,
2935ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                &targ,
2936ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                end,
2937ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                (const char **)&src,
2938ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                (const char *)srcLimit,
2939ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                checkOffsets ? offs : NULL,
2940ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                (UBool)(srcLimit == realSourceEnd), /* flush if we're at the end of the source data */
2941ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                &status);
2942ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    } while ( (status == U_BUFFER_OVERFLOW_ERROR) || (U_SUCCESS(status) && (srcLimit < realSourceEnd)) ); /* while we just need another buffer */
2943ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2944ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(status==U_INVALID_CHAR_FOUND || status == U_ILLEGAL_CHAR_FOUND){
2945ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        char errChars[50]; /* should be sufficient */
2946ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int8_t errLen = 50;
2947ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UErrorCode err = U_ZERO_ERROR;
2948ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const char* limit= NULL;
2949ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const char* start= NULL;
2950ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ucnv_getInvalidChars(conv,errChars, &errLen, &err);
2951ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(U_FAILURE(err)){
2952ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("ucnv_getInvalidChars failed with error : %s\n",u_errorName(err));
2953ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2954ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* src points to limit of invalid chars */
2955ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        limit = src;
2956ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        /* length of in invalid chars should be equal to returned length*/
2957ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        start = src - errLen;
2958ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(uprv_strncmp(errChars,start,errLen)!=0){
2959ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("ucnv_getInvalidChars did not return the correct invalid chars for encoding %s \n", ucnv_getName(conv,&err));
2960ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2961ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2962ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /* allow failure codes for the stop callback */
2963ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(U_FAILURE(status) &&
2964ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru       (callback != UCNV_TO_U_CALLBACK_STOP || (status != U_INVALID_CHAR_FOUND && status != U_ILLEGAL_CHAR_FOUND && status != U_TRUNCATED_CHAR_FOUND)))
2965ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2966ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Problem doing toUnicode, errcode %s %s\n", myErrorName(status), gNuConvTestName);
2967ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return FALSE;
2968ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2969ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2970ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("\nConversion done. %d bytes -> %d chars.\nResult :",
2971ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        sourcelen, targ-junkout);
297227f654740f2a26ad62a5c155af9199af9e69b889claireho    if(getTestOption(VERBOSITY_OPTION))
2973ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2974ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2975ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        junk[0] = 0;
2976ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        offset_str[0] = 0;
2977ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2978ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        for(p = junkout;p<targ;p++)
2979ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
2980ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            sprintf(junk + strlen(junk), "0x%04x, ", (0xFFFF) & (unsigned int)*p);
2981ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            sprintf(offset_str + strlen(offset_str), "0x%04x, ", (0xFFFF) & (unsigned int)junokout[p-junkout]);
2982ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2983ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2984ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose(junk);
2985ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printUSeq(expect, expectlen);
2986ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if ( checkOffsets )
2987ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
2988ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_verbose("\nOffsets:");
2989ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_verbose(offset_str);
2990ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
2991ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("\n");
2992ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
2993ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ucnv_close(conv);
2994ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2995ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("comparing %d uchars (%d bytes)..\n",expectlen,expectlen*2);
2996ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2997ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (checkOffsets && (expectOffsets != 0))
2998ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
2999ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(memcmp(junokout,expectOffsets,(targ-junkout) * sizeof(int32_t)))
3000ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
3001ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("did not get the expected offsets while %s \n", gNuConvTestName);
3002ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Got offsets:      ");
3003ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            for(p=junkout;p<targ;p++)
3004ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("  %2d,", junokout[p-junkout]);
3005ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("\n");
3006ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Expected offsets: ");
3007ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            for(i=0; i<(targ-junkout); i++)
3008ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("  %2d,", expectOffsets[i]);
3009ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("\n");
3010ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Got output:       ");
3011ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            for(i=0; i<(targ-junkout); i++)
3012ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("0x%04x,", junkout[i]);
3013ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("\n");
3014ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("From source:      ");
3015ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            for(i=0; i<(src-(const char *)source); i++)
3016ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("  0x%02x,", (unsigned char)source[i]);
3017ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("\n");
3018ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
3019ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3020ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3021ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!memcmp(junkout, expect, expectlen*2))
3022ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3023ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("Matches!\n");
3024ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return TRUE;
3025ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3026ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    else
3027ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3028ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("String does not match. %s\n", gNuConvTestName);
3029ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("String does not match. %s\n", gNuConvTestName);
3030ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Got:      ");
3031ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printUSeqErr(junkout, expectlen);
3032ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Expected: ");
3033ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printUSeqErr(expect, expectlen);
3034ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("\n");
3035ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return FALSE;
3036ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3037ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
3038ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3039ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruUBool testConvertFromUnicodeWithContext(const UChar *source, int sourceLen,  const uint8_t *expect, int expectLen,
3040ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                const char *codepage, UConverterFromUCallback callback , const int32_t *expectOffsets,
3041ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                const char *mySubChar, int8_t len, const void* context, UErrorCode expectedError)
3042ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
3043ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3044ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3045ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
3046ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UConverter *conv = 0;
3047ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char junkout[NEW_MAX_BUFFER]; /* FIX */
3048ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t junokout[NEW_MAX_BUFFER]; /* FIX */
3049ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const UChar *src;
3050ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char *end;
3051ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char *targ;
3052ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t *offs;
3053ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int i;
3054ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t  realBufferSize;
3055ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char *realBufferEnd;
3056ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const UChar *realSourceEnd;
3057ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const UChar *sourceLimit;
3058ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool checkOffsets = TRUE;
3059ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool doFlush;
3060ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char junk[9999];
3061ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char offset_str[9999];
3062ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char *p;
3063ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UConverterFromUCallback oldAction = NULL;
3064ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const void* oldContext = NULL;
3065ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3066ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3067ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    for(i=0;i<NEW_MAX_BUFFER;i++)
3068ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        junkout[i] = (char)0xF0;
3069ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    for(i=0;i<NEW_MAX_BUFFER;i++)
3070ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        junokout[i] = 0xFF;
3071ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    setNuConvTestName(codepage, "FROM");
3072ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3073ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("\nTesting========= %s  FROM \n  inputbuffer= %d   outputbuffer= %d\n", codepage, gInBufferSize,
3074ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            gOutBufferSize);
3075ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3076ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    conv = ucnv_open(codepage, &status);
3077ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(U_FAILURE(status))
3078ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3079ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_data_err("Couldn't open converter %s\n",codepage);
3080ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return TRUE; /* Because the err has already been logged. */
3081ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3082ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3083ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Converter opened..\n");
3084ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3085ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*----setting the callback routine----*/
3086ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ucnv_setFromUCallBack (conv, callback, context, &oldAction, &oldContext, &status);
3087ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (U_FAILURE(status))
3088ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3089ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("FAILURE in setting the callback Function! %s\n", myErrorName(status));
3090ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3091ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*------------------------*/
3092ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*setting the subChar*/
3093ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(mySubChar != NULL){
3094ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ucnv_setSubstChars(conv, mySubChar, len, &status);
3095ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if (U_FAILURE(status))  {
3096ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("FAILURE in setting substitution chars! %s\n", myErrorName(status));
3097ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
3098ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3099ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*------------*/
3100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    src = source;
3102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    targ = junkout;
3103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    offs = junokout;
3104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    realBufferSize = (sizeof(junkout)/sizeof(junkout[0]));
3106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    realBufferEnd = junkout + realBufferSize;
3107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    realSourceEnd = source + sourceLen;
3108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if ( gOutBufferSize != realBufferSize )
3110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      checkOffsets = FALSE;
3111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if( gInBufferSize != NEW_MAX_BUFFER )
3113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      checkOffsets = FALSE;
3114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    do
3116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        end = nct_min(targ + gOutBufferSize, realBufferEnd);
3118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        sourceLimit = nct_min(src + gInBufferSize, realSourceEnd);
3119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        doFlush = (UBool)(sourceLimit == realSourceEnd);
3121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(targ == realBufferEnd)
3123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
3124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Error, overflowed the real buffer while about to call fromUnicode! targ=%08lx %s", targ, gNuConvTestName);
3125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            return FALSE;
3126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
3127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("calling fromUnicode @ SOURCE:%08lx to %08lx  TARGET: %08lx to %08lx, flush=%s\n", src,sourceLimit, targ,end, doFlush?"TRUE":"FALSE");
3128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        status = U_ZERO_ERROR;
3131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ucnv_fromUnicode (conv,
3133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  (char **)&targ,
3134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  (const char *)end,
3135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  &src,
3136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  sourceLimit,
3137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  checkOffsets ? offs : NULL,
3138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  doFlush, /* flush if we're at the end of the input data */
3139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  &status);
3140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    } while ( (status == U_BUFFER_OVERFLOW_ERROR) || (U_SUCCESS(status) && (sourceLimit < realSourceEnd)) );
3141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /* allow failure codes for the stop callback */
3143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(U_FAILURE(status) && status != expectedError)
3144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Problem in fromUnicode, errcode %s %s\n", myErrorName(status), gNuConvTestName);
3146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return FALSE;
3147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("\nConversion done [%d uchars in -> %d chars out]. \nResult :",
3150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        sourceLen, targ-junkout);
315127f654740f2a26ad62a5c155af9199af9e69b889claireho    if(getTestOption(VERBOSITY_OPTION))
3152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        junk[0] = 0;
3155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        offset_str[0] = 0;
3156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        for(p = junkout;p<targ;p++)
3157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
3158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            sprintf(junk + strlen(junk), "0x%02x, ", (0xFF) & (unsigned int)*p);
3159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            sprintf(offset_str + strlen(offset_str), "0x%02x, ", (0xFF) & (unsigned int)junokout[p-junkout]);
3160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
3161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose(junk);
3163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printSeq(expect, expectLen);
3164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if ( checkOffsets )
3165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
3166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_verbose("\nOffsets:");
3167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_verbose(offset_str);
3168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
3169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("\n");
3170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ucnv_close(conv);
3172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(expectLen != targ-junkout)
3175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Expected %d chars out, got %d %s\n", expectLen, targ-junkout, gNuConvTestName);
3177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("Expected %d chars out, got %d %s\n", expectLen, targ-junkout, gNuConvTestName);
3178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printSeqErr((const uint8_t *)junkout, (int32_t)(targ-junkout));
3179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printSeqErr(expect, expectLen);
3180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return FALSE;
3181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (checkOffsets && (expectOffsets != 0) )
3184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("comparing %d offsets..\n", targ-junkout);
3186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(memcmp(junokout,expectOffsets,(targ-junkout) * sizeof(int32_t) )){
3187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("did not get the expected offsets while %s \n", gNuConvTestName);
3188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Got Output : ");
3189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            printSeqErr((const uint8_t *)junkout, (int32_t)(targ-junkout));
3190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Got Offsets:      ");
3191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            for(p=junkout;p<targ;p++)
3192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("%d,", junokout[p-junkout]);
3193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("\n");
3194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Expected Offsets: ");
3195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            for(i=0; i<(targ-junkout); i++)
3196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("%d,", expectOffsets[i]);
3197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("\n");
3198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            return FALSE;
3199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
3200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!memcmp(junkout, expect, expectLen))
3203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("String matches! %s\n", gNuConvTestName);
3205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return TRUE;
3206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    else
3208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("String does not match. %s\n", gNuConvTestName);
3210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("source: ");
3211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printUSeqErr(source, sourceLen);
3212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Got:      ");
3213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printSeqErr((const uint8_t *)junkout, expectLen);
3214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Expected: ");
3215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printSeqErr(expect, expectLen);
3216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return FALSE;
3217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
3219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruUBool testConvertToUnicodeWithContext( const uint8_t *source, int sourcelen, const UChar *expect, int expectlen,
3220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru               const char *codepage, UConverterToUCallback callback, const int32_t *expectOffsets,
3221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru               const char *mySubChar, int8_t len, const void* context, UErrorCode expectedError)
3222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
3223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
3224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UConverter *conv = 0;
3225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UChar   junkout[NEW_MAX_BUFFER]; /* FIX */
3226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t junokout[NEW_MAX_BUFFER]; /* FIX */
3227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const char *src;
3228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const char *realSourceEnd;
3229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const char *srcLimit;
3230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UChar *targ;
3231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UChar *end;
3232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t *offs;
3233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int i;
3234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool   checkOffsets = TRUE;
3235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char junk[9999];
3236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char offset_str[9999];
3237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UChar *p;
3238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UConverterToUCallback oldAction = NULL;
3239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const void* oldContext = NULL;
3240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t   realBufferSize;
3242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UChar *realBufferEnd;
3243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    for(i=0;i<NEW_MAX_BUFFER;i++)
3246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        junkout[i] = 0xFFFE;
3247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    for(i=0;i<NEW_MAX_BUFFER;i++)
3249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        junokout[i] = -1;
3250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    setNuConvTestName(codepage, "TO");
3252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("\n=========  %s\n", gNuConvTestName);
3254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    conv = ucnv_open(codepage, &status);
3256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(U_FAILURE(status))
3257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_data_err("Couldn't open converter %s\n",gNuConvTestName);
3259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return TRUE;
3260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("Converter opened..\n");
3263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    src = (const char *)source;
3265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    targ = junkout;
3266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    offs = junokout;
3267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    realBufferSize = (sizeof(junkout)/sizeof(junkout[0]));
3269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    realBufferEnd = junkout + realBufferSize;
3270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    realSourceEnd = src + sourcelen;
3271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*----setting the callback routine----*/
3272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ucnv_setToUCallBack (conv, callback, context, &oldAction, &oldContext, &status);
3273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (U_FAILURE(status))
3274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("FAILURE in setting the callback Function! %s\n", myErrorName(status));
3276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*-------------------------------------*/
3278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*setting the subChar*/
3279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(mySubChar != NULL){
3280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ucnv_setSubstChars(conv, mySubChar, len, &status);
3281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if (U_FAILURE(status))  {
3282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("FAILURE in setting the callback Function! %s\n", myErrorName(status));
3283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
3284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*------------*/
3286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if ( gOutBufferSize != realBufferSize )
3289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        checkOffsets = FALSE;
3290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if( gInBufferSize != NEW_MAX_BUFFER )
3292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        checkOffsets = FALSE;
3293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    do
3295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        end = nct_min( targ + gOutBufferSize, realBufferEnd);
3297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        srcLimit = nct_min(realSourceEnd, src + gInBufferSize);
3298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(targ == realBufferEnd)
3300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
3301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Error, the end would overflow the real output buffer while about to call toUnicode! tarjey=%08lx %s",targ,gNuConvTestName);
3302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            return FALSE;
3303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
3304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("calling toUnicode @ %08lx to %08lx\n", targ,end);
3305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        status = U_ZERO_ERROR;
3309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        ucnv_toUnicode (conv,
3311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                &targ,
3312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                end,
3313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                (const char **)&src,
3314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                (const char *)srcLimit,
3315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                checkOffsets ? offs : NULL,
3316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                (UBool)(srcLimit == realSourceEnd), /* flush if we're at the end of the source data */
3317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                &status);
3318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    } while ( (status == U_BUFFER_OVERFLOW_ERROR) || (U_SUCCESS(status) && (srcLimit < realSourceEnd)) ); /* while we just need another buffer */
3319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /* allow failure codes for the stop callback */
3321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(U_FAILURE(status) && status!=expectedError)
3322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Problem doing toUnicode, errcode %s %s\n", myErrorName(status), gNuConvTestName);
3324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return FALSE;
3325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("\nConversion done. %d bytes -> %d chars.\nResult :",
3328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        sourcelen, targ-junkout);
332927f654740f2a26ad62a5c155af9199af9e69b889claireho    if(getTestOption(VERBOSITY_OPTION))
3330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        junk[0] = 0;
3333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        offset_str[0] = 0;
3334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        for(p = junkout;p<targ;p++)
3336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
3337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            sprintf(junk + strlen(junk), "0x%04x, ", (0xFFFF) & (unsigned int)*p);
3338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            sprintf(offset_str + strlen(offset_str), "0x%04x, ", (0xFFFF) & (unsigned int)junokout[p-junkout]);
3339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
3340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose(junk);
3342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printUSeq(expect, expectlen);
3343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if ( checkOffsets )
3344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
3345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_verbose("\nOffsets:");
3346ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_verbose(offset_str);
3347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
3348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("\n");
3349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ucnv_close(conv);
3351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    log_verbose("comparing %d uchars (%d bytes)..\n",expectlen,expectlen*2);
3353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3354ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (checkOffsets && (expectOffsets != 0))
3355ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        if(memcmp(junokout,expectOffsets,(targ-junkout) * sizeof(int32_t)))
3357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        {
3358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("did not get the expected offsets while %s \n", gNuConvTestName);
3359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Got offsets:      ");
3360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            for(p=junkout;p<targ;p++)
3361ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("  %2d,", junokout[p-junkout]);
3362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("\n");
3363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Expected offsets: ");
3364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            for(i=0; i<(targ-junkout); i++)
3365ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("  %2d,", expectOffsets[i]);
3366ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("\n");
3367ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("Got output:       ");
3368ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            for(i=0; i<(targ-junkout); i++)
3369ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("0x%04x,", junkout[i]);
3370ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("\n");
3371ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("From source:      ");
3372ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            for(i=0; i<(src-(const char *)source); i++)
3373ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                log_err("  0x%02x,", (unsigned char)source[i]);
3374ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            log_err("\n");
3375ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
3376ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3377ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3378ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(!memcmp(junkout, expect, expectlen*2))
3379ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3380ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("Matches!\n");
3381ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return TRUE;
3382ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3383ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    else
3384ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
3385ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("String does not match. %s\n", gNuConvTestName);
3386ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_verbose("String does not match. %s\n", gNuConvTestName);
3387ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Got:      ");
3388ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printUSeqErr(junkout, expectlen);
3389ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Expected: ");
3390ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        printUSeqErr(expect, expectlen);
3391ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("\n");
3392ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return FALSE;
3393ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3394ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
3395ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3396ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustatic void TestCallBackFailure(void) {
3397ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UErrorCode status = U_USELESS_COLLATOR_ERROR;
3398ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ucnv_cbFromUWriteBytes(NULL, NULL, -1, -1, &status);
3399ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (status != U_USELESS_COLLATOR_ERROR) {
3400ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Error: ucnv_cbFromUWriteBytes did not react correctly to a bad UErrorCode\n");
3401ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3402ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ucnv_cbFromUWriteUChars(NULL, NULL, NULL, -1, &status);
3403ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (status != U_USELESS_COLLATOR_ERROR) {
3404ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Error: ucnv_cbFromUWriteUChars did not react correctly to a bad UErrorCode\n");
3405ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3406ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ucnv_cbFromUWriteSub(NULL, -1, &status);
3407ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (status != U_USELESS_COLLATOR_ERROR) {
3408ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Error: ucnv_cbFromUWriteSub did not react correctly to a bad UErrorCode\n");
3409ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3410ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    ucnv_cbToUWriteUChars(NULL, NULL, -1, -1, &status);
3411ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (status != U_USELESS_COLLATOR_ERROR) {
3412ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        log_err("Error: ucnv_cbToUWriteUChars did not react correctly to a bad UErrorCode\n");
3413ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
3414ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
3415