OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [testsuite/] [newlib.iconv/] [iconvru.c] - Blame information for rev 252

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * Copyright (c) 2003, Artem B. Bityuckiy, SoftMine Corporation.
3
 * Rights transferred to Franklin Electronic Publishers.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 * SUCH DAMAGE.
25
 */
26
#include <stdio.h>
27
#include <stdlib.h>
28
#include <iconv.h>
29
#include <errno.h>
30
#include <newlib.h>
31
#include "check.h"
32
 
33
#ifdef _ICONV_ENABLED
34
 
35
#if defined(_ICONV_CONVERTER_UTF_8) || \
36
    defined(_ICONV_CONVERTER_ISO_8859_5) || \
37
    defined(_ICONV_CONVERTER_KOI8_R)
38
 
39
#ifdef _ICONV_CONVERTER_ISO_8859_5
40
char iso_8859_5[] =
41
{
42
    0xbe,0xdf,0xd5,0xe0,0xd0,0xe2,0xde,0xe0,0xeb,0x20,
43
    0xd2,0x20,0xde,0xd4,0xdd,0xde,0xd9,0x20,0xe1,0xe2,
44
    0xe0,0xde,0xda,0xd5,0x20,0xd8,0xdc,0xd5,0xee,0xe2,
45
    0x20,0xde,0xd4,0xd8,0xdd,0xd0,0xda,0xde,0xd2,0xeb,
46
    0xd9,0x20,0xdf,0xe0,0xd8,0xde,0xe0,0xd8,0xe2,0xd5,
47
    0xe2,0x0a,0xc1,0xe2,0xe0,0xde,0xda,0xd8,0x20,0xe3,
48
    0xdf,0xde,0xe0,0xef,0xd4,0xde,0xe7,0xd5,0xdd,0xeb,
49
    0x20,0xdf,0xde,0x20,0xe3,0xd1,0xeb,0xd2,0xd0,0xdd,
50
    0xd8,0xee,0x20,0xdf,0xe0,0xd8,0xde,0xe0,0xd8,0xe2,
51
    0xd5,0xe2,0xde,0xd2,0x2e,0x0a,0x0a,0x2d,0x2d,0x2d,
52
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
53
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
54
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
55
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
56
    0x2d,0x2d,0x2d,0x2d,0x20,0xb2,0xeb,0xdf,0xde,0xdb,
57
    0xdd,0xd5,0xdd,0xd8,0xd5,0x20,0x2d,0x2d,0x2d,0x2d,
58
    0x2d,0x2d,0x2d,0x2d,0x2d,0x0a,0x28,0x29,0x20,0x20,
59
    0x5b,0x5d,0x20,0x20,0x2d,0x3e,0x20,0x20,0x2e,0x20,
60
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
61
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
62
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
63
    0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x21,
64
    0x20,0x20,0x20,0x7e,0x20,0x20,0x20,0x2b,0x2b,0x20,
65
    0x20,0x2d,0x2d,0x20,0x20,0x2b,0x20,0x20,0x2d,0x20,
66
    0x20,0x2a,0x20,0x20,0x26,0x20,0x20,0x28,0x74,0x79,
67
    0x70,0x65,0x29,0x20,0x20,0x73,0x69,0x7a,0x65,0x6f,
68
    0x66,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,
69
    0x3e,0x0a,0x2a,0x20,0x20,0x2f,0x20,0x20,0x25,0x20,
70
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
71
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
72
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
73
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
74
    0x2d,0x2d,0x2d,0x3e,0x0a,0x2b,0x20,0x20,0x2d,0x20,
75
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
76
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
77
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
78
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
79
    0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x3c,0x3c,
80
    0x20,0x20,0x3e,0x3e,0x20,0x20,0x20,0x20,0x20,0x20,
81
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
82
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
83
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
84
    0x20,0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,
85
    0x0a,0x3c,0x20,0x20,0x3c,0x3d,0x20,0x20,0x3e,0x20,
86
    0x20,0x3e,0x3d,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
87
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
88
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
89
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,
90
    0x2d,0x2d,0x3e,0x0a,0x3d,0x3d,0x20,0x20,0x21,0x3d,
91
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
92
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
93
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
94
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
95
    0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x26,0x20,0x20,
96
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
97
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
98
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
99
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
100
    0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,
101
    0x5e,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
102
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
103
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
104
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
105
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,
106
    0x2d,0x3e,0x0a,0x7c,0x20,0x20,0x20,0x20,0x20,0x20,
107
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
108
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
109
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
110
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
111
    0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x26,0x26,0x20,0x20,
112
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
113
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
114
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
115
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
116
    0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x7c,
117
    0x7c,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
118
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
119
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
120
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
121
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,
122
    0x3e,0x0a,0x3f,0x3a,0x20,0x20,0x20,0x20,0x20,0x20,
123
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
124
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
125
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
126
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
127
    0x3c,0x2d,0x2d,0x2d,0x20,0x20,0x20,0x0a,0x3d,0x20,
128
    0x20,0x2b,0x3d,0x20,0x20,0x2d,0x3d,0x20,0x20,0x2f,
129
    0x3d,0x20,0x20,0x25,0x3d,0x20,0x20,0x26,0x3d,0x20,
130
    0x20,0x5e,0x3d,0x20,0x20,0x7c,0x3d,0x20,0x20,0x3c,
131
    0x3c,0x3d,0x20,0x20,0x3e,0x3e,0x3d,0x20,0x20,0x20,
132
    0x20,0x20,0x20,0x20,0x20,0x20,0x3c,0x2d,0x2d,0x2d,
133
    0x0a,0x2c,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
134
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
135
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
136
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
137
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,
138
    0x2d,0x2d,0x3e,0x0a
139
};
140
#endif /* #ifdef _ICONV_CONVERTER_ISO_8859_5 */
141
 
142
#ifdef _ICONV_CONVERTER_KOI8_R
143
char koi8_r[] =
144
{
145
    0xef,0xd0,0xc5,0xd2,0xc1,0xd4,0xcf,0xd2,0xd9,0x20,
146
    0xd7,0x20,0xcf,0xc4,0xce,0xcf,0xca,0x20,0xd3,0xd4,
147
    0xd2,0xcf,0xcb,0xc5,0x20,0xc9,0xcd,0xc5,0xc0,0xd4,
148
    0x20,0xcf,0xc4,0xc9,0xce,0xc1,0xcb,0xcf,0xd7,0xd9,
149
    0xca,0x20,0xd0,0xd2,0xc9,0xcf,0xd2,0xc9,0xd4,0xc5,
150
    0xd4,0x0a,0xf3,0xd4,0xd2,0xcf,0xcb,0xc9,0x20,0xd5,
151
    0xd0,0xcf,0xd2,0xd1,0xc4,0xcf,0xde,0xc5,0xce,0xd9,
152
    0x20,0xd0,0xcf,0x20,0xd5,0xc2,0xd9,0xd7,0xc1,0xce,
153
    0xc9,0xc0,0x20,0xd0,0xd2,0xc9,0xcf,0xd2,0xc9,0xd4,
154
    0xc5,0xd4,0xcf,0xd7,0x2e,0x0a,0x0a,0x2d,0x2d,0x2d,
155
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
156
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
157
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
158
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
159
    0x2d,0x2d,0x2d,0x2d,0x20,0xf7,0xd9,0xd0,0xcf,0xcc,
160
    0xce,0xc5,0xce,0xc9,0xc5,0x20,0x2d,0x2d,0x2d,0x2d,
161
    0x2d,0x2d,0x2d,0x2d,0x2d,0x0a,0x28,0x29,0x20,0x20,
162
    0x5b,0x5d,0x20,0x20,0x2d,0x3e,0x20,0x20,0x2e,0x20,
163
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
164
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
165
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
166
    0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x21,
167
    0x20,0x20,0x20,0x7e,0x20,0x20,0x20,0x2b,0x2b,0x20,
168
    0x20,0x2d,0x2d,0x20,0x20,0x2b,0x20,0x20,0x2d,0x20,
169
    0x20,0x2a,0x20,0x20,0x26,0x20,0x20,0x28,0x74,0x79,
170
    0x70,0x65,0x29,0x20,0x20,0x73,0x69,0x7a,0x65,0x6f,
171
    0x66,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,
172
    0x3e,0x0a,0x2a,0x20,0x20,0x2f,0x20,0x20,0x25,0x20,
173
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
174
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
175
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
176
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
177
    0x2d,0x2d,0x2d,0x3e,0x0a,0x2b,0x20,0x20,0x2d,0x20,
178
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
179
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
180
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
181
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
182
    0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x3c,0x3c,
183
    0x20,0x20,0x3e,0x3e,0x20,0x20,0x20,0x20,0x20,0x20,
184
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
185
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
186
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
187
    0x20,0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,
188
    0x0a,0x3c,0x20,0x20,0x3c,0x3d,0x20,0x20,0x3e,0x20,
189
    0x20,0x3e,0x3d,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
190
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
191
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
192
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,
193
    0x2d,0x2d,0x3e,0x0a,0x3d,0x3d,0x20,0x20,0x21,0x3d,
194
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
195
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
196
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
197
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
198
    0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x26,0x20,0x20,
199
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
200
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
201
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
202
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
203
    0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,
204
    0x5e,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
205
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
206
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
207
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
208
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,
209
    0x2d,0x3e,0x0a,0x7c,0x20,0x20,0x20,0x20,0x20,0x20,
210
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
211
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
212
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
213
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
214
    0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x26,0x26,0x20,0x20,
215
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
216
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
217
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
218
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
219
    0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x7c,
220
    0x7c,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
221
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
222
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
223
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
224
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,
225
    0x3e,0x0a,0x3f,0x3a,0x20,0x20,0x20,0x20,0x20,0x20,
226
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
227
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
228
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
229
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
230
    0x3c,0x2d,0x2d,0x2d,0x20,0x20,0x20,0x0a,0x3d,0x20,
231
    0x20,0x2b,0x3d,0x20,0x20,0x2d,0x3d,0x20,0x20,0x2f,
232
    0x3d,0x20,0x20,0x25,0x3d,0x20,0x20,0x26,0x3d,0x20,
233
    0x20,0x5e,0x3d,0x20,0x20,0x7c,0x3d,0x20,0x20,0x3c,
234
    0x3c,0x3d,0x20,0x20,0x3e,0x3e,0x3d,0x20,0x20,0x20,
235
    0x20,0x20,0x20,0x20,0x20,0x20,0x3c,0x2d,0x2d,0x2d,
236
    0x0a,0x2c,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
237
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
238
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
239
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
240
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,
241
    0x2d,0x2d,0x3e,0x0a
242
};
243
#endif /* #ifdef _ICONV_CONVERTER_KOI8_R */
244
 
245
#ifdef _ICONV_CONVERTER_UTF_8
246
char utf8[] =
247
{
248
    0xd0,0x9e,0xd0,0xbf,0xd0,0xb5,0xd1,0x80,0xd0,0xb0,
249
    0xd1,0x82,0xd0,0xbe,0xd1,0x80,0xd1,0x8b,0x20,0xd0,
250
    0xb2,0x20,0xd0,0xbe,0xd0,0xb4,0xd0,0xbd,0xd0,0xbe,
251
    0xd0,0xb9,0x20,0xd1,0x81,0xd1,0x82,0xd1,0x80,0xd0,
252
    0xbe,0xd0,0xba,0xd0,0xb5,0x20,0xd0,0xb8,0xd0,0xbc,
253
    0xd0,0xb5,0xd1,0x8e,0xd1,0x82,0x20,0xd0,0xbe,0xd0,
254
    0xb4,0xd0,0xb8,0xd0,0xbd,0xd0,0xb0,0xd0,0xba,0xd0,
255
    0xbe,0xd0,0xb2,0xd1,0x8b,0xd0,0xb9,0x20,0xd0,0xbf,
256
    0xd1,0x80,0xd0,0xb8,0xd0,0xbe,0xd1,0x80,0xd0,0xb8,
257
    0xd1,0x82,0xd0,0xb5,0xd1,0x82,0x0a,0xd0,0xa1,0xd1,
258
    0x82,0xd1,0x80,0xd0,0xbe,0xd0,0xba,0xd0,0xb8,0x20,
259
    0xd1,0x83,0xd0,0xbf,0xd0,0xbe,0xd1,0x80,0xd1,0x8f,
260
    0xd0,0xb4,0xd0,0xbe,0xd1,0x87,0xd0,0xb5,0xd0,0xbd,
261
    0xd1,0x8b,0x20,0xd0,0xbf,0xd0,0xbe,0x20,0xd1,0x83,
262
    0xd0,0xb1,0xd1,0x8b,0xd0,0xb2,0xd0,0xb0,0xd0,0xbd,
263
    0xd0,0xb8,0xd1,0x8e,0x20,0xd0,0xbf,0xd1,0x80,0xd0,
264
    0xb8,0xd0,0xbe,0xd1,0x80,0xd0,0xb8,0xd1,0x82,0xd0,
265
    0xb5,0xd1,0x82,0xd0,0xbe,0xd0,0xb2,0x2e,0x0a,0x0a,
266
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
267
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
268
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
269
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
270
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x20,0xd0,0x92,
271
    0xd1,0x8b,0xd0,0xbf,0xd0,0xbe,0xd0,0xbb,0xd0,0xbd,
272
    0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,0xd0,0xb5,0x20,0x2d,
273
    0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x0a,0x28,
274
    0x29,0x20,0x20,0x5b,0x5d,0x20,0x20,0x2d,0x3e,0x20,
275
    0x20,0x2e,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
276
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
277
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
278
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,
279
    0x3e,0x0a,0x21,0x20,0x20,0x20,0x7e,0x20,0x20,0x20,
280
    0x2b,0x2b,0x20,0x20,0x2d,0x2d,0x20,0x20,0x2b,0x20,
281
    0x20,0x2d,0x20,0x20,0x2a,0x20,0x20,0x26,0x20,0x20,
282
    0x28,0x74,0x79,0x70,0x65,0x29,0x20,0x20,0x73,0x69,
283
    0x7a,0x65,0x6f,0x66,0x20,0x20,0x20,0x20,0x20,0x20,
284
    0x2d,0x2d,0x2d,0x3e,0x0a,0x2a,0x20,0x20,0x2f,0x20,
285
    0x20,0x25,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
286
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
287
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
288
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
289
    0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x2b,0x20,
290
    0x20,0x2d,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
291
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
292
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
293
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
294
    0x20,0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,
295
    0x0a,0x3c,0x3c,0x20,0x20,0x3e,0x3e,0x20,0x20,0x20,
296
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
297
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
298
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
299
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,
300
    0x2d,0x2d,0x3e,0x0a,0x3c,0x20,0x20,0x3c,0x3d,0x20,
301
    0x20,0x3e,0x20,0x20,0x3e,0x3d,0x20,0x20,0x20,0x20,
302
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
303
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
304
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
305
    0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x3d,0x3d,0x20,
306
    0x20,0x21,0x3d,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
307
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
308
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
309
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
310
    0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,
311
    0x26,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
312
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
313
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
314
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
315
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,
316
    0x2d,0x3e,0x0a,0x5e,0x20,0x20,0x20,0x20,0x20,0x20,
317
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
318
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
319
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
320
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
321
    0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x7c,0x20,0x20,0x20,
322
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
323
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
324
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
325
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
326
    0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a,0x26,
327
    0x26,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
328
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
329
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
330
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
331
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x2d,0x2d,0x2d,
332
    0x3e,0x0a,0x7c,0x7c,0x20,0x20,0x20,0x20,0x20,0x20,
333
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
334
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
335
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
336
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
337
    0x2d,0x2d,0x2d,0x3e,0x0a,0x3f,0x3a,0x20,0x20,0x20,
338
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
339
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
340
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
341
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
342
    0x20,0x20,0x20,0x3c,0x2d,0x2d,0x2d,0x20,0x20,0x20,
343
    0x0a,0x3d,0x20,0x20,0x2b,0x3d,0x20,0x20,0x2d,0x3d,
344
    0x20,0x20,0x2f,0x3d,0x20,0x20,0x25,0x3d,0x20,0x20,
345
    0x26,0x3d,0x20,0x20,0x5e,0x3d,0x20,0x20,0x7c,0x3d,
346
    0x20,0x20,0x3c,0x3c,0x3d,0x20,0x20,0x3e,0x3e,0x3d,
347
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3c,
348
    0x2d,0x2d,0x2d,0x0a,0x2c,0x20,0x20,0x20,0x20,0x20,
349
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
350
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
351
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
352
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
353
    0x20,0x20,0x2d,0x2d,0x2d,0x3e,0x0a
354
};
355
#endif
356
 
357
struct iconv_data
358
{
359
    int len;
360
    char *name;
361
    char *data;
362
};
363
 
364
#define CONVERSIONS 3
365
 
366
struct iconv_data data[] =
367
{
368
#ifdef _ICONV_CONVERTER_ISO_8859_5
369
    {sizeof(iso_8859_5), "ISO-8859-5", (char *)iso_8859_5},
370
#endif
371
#ifdef _ICONV_CONVERTER_KOI8_R
372
    {sizeof(koi8_r), "KOI8-R", (char *)koi8_r},
373
#endif
374
#ifdef _ICONV_CONVERTER_UTF_8
375
    {sizeof(utf8), "UTF-8", (char *)utf8},
376
#endif
377
    {0, NULL, NULL}
378
};
379
 
380
#define OUTBUF_LEN 1500
381
char ob[OUTBUF_LEN];
382
 
383
iconv_t descs[CONVERSIONS*CONVERSIONS];
384
 
385
#define ERROR 0
386
 
387
int main(int argc, char **argv)
388
{
389
    int i, j, k, d = 0;
390
    size_t n;
391
    char *outbuf, *inbuf;
392
    int conversions = sizeof(data)/sizeof(struct iconv_data) - 1;
393
 
394
    puts("RU iconv test");
395
 
396
    for (i = 0; i < conversions; i++)
397
    {
398
        for (j = 0; j < conversions; j++)
399
        {
400
            descs[d] = iconv_open(data[j].name, data[i].name);
401
            if (descs[d++] == (iconv_t)-1)
402
            {
403
                printf("iconv_open(%s, %s)\n", data[i].name, data[j].name);
404
                perror("");
405
                CHECK(ERROR);
406
            }
407
        }
408
    }
409
 
410
    d = 0;
411
    for (i = 0; i < conversions; i++)
412
    {
413
        for (j = 0; j < conversions; j++)
414
        {
415
            size_t inbytes = data[i].len;
416
            size_t outbytes = OUTBUF_LEN;
417
            inbuf = data[i].data;
418
            outbuf = (char *)ob;
419
 
420
            if (iconv(descs[d], NULL, NULL, (char **)&outbuf, &outbytes)                                                                       == (size_t)-1)
421
            {
422
                perror("Can't reset shift state");
423
                CHECK(ERROR);
424
            }
425
 
426
            n = iconv(descs[d++], (const char **)&(inbuf), &inbytes,
427
                                  (char **)&outbuf, &outbytes);
428
            if (n == (size_t)-1)
429
            {
430
                printf("Conversion from %s to %s FAILED - iconv() "
431
                       "returned -1\n", data[i].name, data[j].name);
432
                perror("");
433
                CHECK(ERROR);
434
            }
435
 
436
            if (data[j].len != OUTBUF_LEN - outbytes)
437
            {
438
                printf("Conversion from %s to %s FAILED",
439
                       data[i].name, data[j].name);
440
                printf(" - bad output buffer length (%d instead of %d)\n",
441
                       OUTBUF_LEN - outbytes, data[j].len);
442
                CHECK(ERROR);
443
            }
444
 
445
            for (k = 0; k < data[j].len; k++)
446
            {
447
                if (ob[k] != data[j].data[k])
448
                {
449
                    printf("Conversion from %s to %s FAILED",
450
                           data[i].name, data[j].name);
451
                    printf("Error: byte %d is wrong\n", k);
452
                    printf("outbuf value: %#x, inbuf value %#x, "
453
                           "right value: %#x\n",
454
                           (int)ob[k], (int)(data[i].data[k]),
455
                           (int)(data[j].data[k]));
456
                    CHECK(ERROR);
457
                }
458
            }
459
 
460
            printf("iconv from %s to %s was successfully done\n",
461
                   data[i].name, data[j].name);
462
 
463
        }
464
    }
465
 
466
    d = 0;
467
    for (i = 0; i < conversions; i++)
468
        for (j = 0; j < conversions; j++)
469
            CHECK(iconv_close(descs[d++]) != -1);
470
 
471
    exit(0);
472
}
473
 
474
#else /* #if defined(_ICONV_CONVERTER_UTF_8) || ... */
475
int main(int argc, char **argv)
476
{
477
    puts("None of ISO-8859-5, KOI8-R and UTF-8 converters linked, SKIP test");
478
    exit(0);
479
}
480
#endif /* #if defined(_ICONV_CONVERTER_UTF_8) || ... */
481
 
482
#else /* #ifdef _ICONV_ENABLED */
483
int main(int argc, char **argv)
484
{
485
    puts("iconv library is disabled, SKIP test");
486
    exit(0);
487
}
488
#endif /* #ifdef _ICONV_ENABLED */
489
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.