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