#include "win_iconv.c"
#include <stdio.h>
Go to the source code of this file.
|
#define | STATIC_STRLEN(arr) (sizeof(arr) - 1) |
|
#define | success(from, fromstr, to, tostr) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), 0, BUFSIZ, __LINE__) |
|
#define | einval(from, fromstr, to, tostr) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), EINVAL, BUFSIZ, __LINE__) |
|
#define | eilseq(from, fromstr, to, tostr) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), EILSEQ, BUFSIZ, __LINE__) |
|
#define | e2big(from, fromstr, to, tostr, bufsize) test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), E2BIG, bufsize, __LINE__) |
|
|
const char * | tohex (const char *str, int size) |
|
const char * | errstr (int errcode) |
|
int | check_enc (const char *encname, int codepage) |
|
void | test (const char *from, const char *fromstr, int fromsize, const char *to, const char *tostr, int tosize, int errcode, int bufsize, int line) |
|
int | main (int argc, char **argv) |
|
◆ e2big
#define e2big |
( |
|
from, |
|
|
|
fromstr, |
|
|
|
to, |
|
|
|
tostr, |
|
|
|
bufsize |
|
) |
| test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), E2BIG, bufsize, __LINE__) |
◆ eilseq
#define eilseq |
( |
|
from, |
|
|
|
fromstr, |
|
|
|
to, |
|
|
|
tostr |
|
) |
| test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), EILSEQ, BUFSIZ, __LINE__) |
◆ einval
#define einval |
( |
|
from, |
|
|
|
fromstr, |
|
|
|
to, |
|
|
|
tostr |
|
) |
| test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), EINVAL, BUFSIZ, __LINE__) |
◆ STATIC_STRLEN
◆ success
#define success |
( |
|
from, |
|
|
|
fromstr, |
|
|
|
to, |
|
|
|
tostr |
|
) |
| test(from, fromstr, STATIC_STRLEN(fromstr), to, tostr, STATIC_STRLEN(tostr), 0, BUFSIZ, __LINE__) |
◆ check_enc()
Definition at line 67 of file win_iconv_test.c.
68{
73 {
74 printf(
"%s(%d) IS NOT SUPPORTED: SKIP THE TEST\n", encname,
codepage);
76 }
77#ifndef USE_ICONV_H
80 {
81 printf(
"%s(%d) ALIAS IS MAPPED TO DIFFERENT CODEPAGE (%d)\n", encname,
codepage,
cp);
83 }
84#endif
87}
int iconv_close(iconv_t cd)
iconv_t iconv_open(const char *tocode, const char *fromcode)
Referenced by main().
◆ errstr()
Definition at line 27 of file win_iconv_test.c.
28{
31 {
32 case 0: return "NOERROR";
33 case EINVAL:
return "EINVAL";
34 case EILSEQ:
return "EILSEQ";
35 case E2BIG:
return "E2BIG";
36 }
39}
GLenum GLuint GLenum GLsizei const GLchar * buf
#define sprintf(buf, format,...)
Referenced by csp_hostaddr(), error(), gl_error(), pagesetup_common(), test(), test_FunnyChars(), test_setdir(), test_ValidPathA(), and warning().
◆ main()
Definition at line 164 of file win_iconv_test.c.
165{
166#ifdef USE_LIBICONV_DLL
167
168 if (setdll(""))
169 {
170 success(
"ascii",
"ABC",
"ascii",
"ABC");
171 success(
"ascii",
"ABC",
"utf-16be",
"\x00\x41\x00\x42\x00\x43");
172 }
173 else
174 {
175 printf(
"\nDLL TEST IS SKIPPED\n\n");
176 }
177
178 setdll("none");
179#endif
180
182 {
183 success(
"ascii",
"ABC",
"ascii",
"ABC");
184
185 success(
"ascii",
"\x80\xFF",
"ascii",
"\x00\x7F");
186 }
187
188
192 )
193 {
194
195
196
197 success(
"utf-16",
"\xFE\xFF\x01\x02",
"utf-16be",
"\x01\x02");
198 success(
"utf-16",
"\xFF\xFE\x02\x01",
"utf-16be",
"\x01\x02");
199 success(
"utf-32",
"\x00\x00\xFE\xFF\x00\x00\x01\x02",
"utf-32be",
"\x00\x00\x01\x02");
200 success(
"utf-32",
"\xFF\xFE\x00\x00\x02\x01\x00\x00",
"utf-32be",
"\x00\x00\x01\x02");
201 success(
"utf-16",
"\xFE\xFF\x00\x01",
"utf-8",
"\x01");
202#ifndef GLIB_COMPILATION
203 success(
"utf-8",
"\x01",
"utf-16",
"\xFE\xFF\x00\x01");
204 success(
"utf-8",
"\x01",
"utf-32",
"\x00\x00\xFE\xFF\x00\x00\x00\x01");
205#else
206 success(
"utf-8",
"\x01",
"utf-16",
"\xFF\xFE\x01\x00");
207 success(
"utf-8",
"\x01",
"utf-32",
"\xFF\xFE\x00\x00\x01\x00\x00\x00");
208#endif
209
210 success(
"utf-16be",
"\xFE\xFF\x01\x02",
"utf-16be",
"\xFE\xFF\x01\x02");
211 success(
"utf-16le",
"\xFF\xFE\x02\x01",
"utf-16be",
"\xFE\xFF\x01\x02");
212 success(
"utf-32be",
"\x00\x00\xFE\xFF\x00\x00\x01\x02",
"utf-32be",
"\x00\x00\xFE\xFF\x00\x00\x01\x02");
213 success(
"utf-32le",
"\xFF\xFE\x00\x00\x02\x01\x00\x00",
"utf-32be",
"\x00\x00\xFE\xFF\x00\x00\x01\x02");
214 success(
"utf-16be",
"\xFE\xFF\x00\x01",
"utf-8",
"\xEF\xBB\xBF\x01");
215 success(
"utf-8",
"\xEF\xBB\xBF\x01",
"utf-8",
"\xEF\xBB\xBF\x01");
216
217 success(
"utf-16be",
"\x01\x02",
"utf-16le",
"\x02\x01");
218 success(
"utf-16le",
"\x02\x01",
"utf-16be",
"\x01\x02");
219 success(
"utf-16be",
"\xFE\xFF",
"utf-16le",
"\xFF\xFE");
220 success(
"utf-16le",
"\xFF\xFE",
"utf-16be",
"\xFE\xFF");
221 success(
"utf-32be",
"\x00\x00\x03\x04",
"utf-32le",
"\x04\x03\x00\x00");
222 success(
"utf-32le",
"\x04\x03\x00\x00",
"utf-32be",
"\x00\x00\x03\x04");
223 success(
"utf-32be",
"\x00\x00\xFF\xFF",
"utf-16be",
"\xFF\xFF");
224 success(
"utf-16be",
"\xFF\xFF",
"utf-32be",
"\x00\x00\xFF\xFF");
225 success(
"utf-32be",
"\x00\x01\x00\x00",
"utf-16be",
"\xD8\x00\xDC\x00");
226 success(
"utf-16be",
"\xD8\x00\xDC\x00",
"utf-32be",
"\x00\x01\x00\x00");
227 success(
"utf-32be",
"\x00\x10\xFF\xFF",
"utf-16be",
"\xDB\xFF\xDF\xFF");
228 success(
"utf-16be",
"\xDB\xFF\xDF\xFF",
"utf-32be",
"\x00\x10\xFF\xFF");
229 eilseq(
"utf-32be",
"\x00\x11\x00\x00",
"utf-16be",
"");
230 eilseq(
"utf-16be",
"\xDB\xFF\xE0\x00",
"utf-32be",
"");
231 success(
"utf-8",
"\xE3\x81\x82",
"utf-16be",
"\x30\x42");
232 einval(
"utf-8",
"\xE3",
"utf-16be",
"");
233 }
234
235
240 {
241
242
243 success(
"utf-16be",
"\xFF\x5E",
"cp932",
"\x81\x60");
244 success(
"utf-16be",
"\x30\x1C",
"cp932",
"\x81\x60");
245 success(
"utf-16be",
"\xFF\x5E",
"cp932//nocompat",
"\x81\x60");
246 eilseq(
"utf-16be",
"\x30\x1C",
"cp932//nocompat",
"");
247 success(
"euc-jp",
"\xA4\xA2",
"utf-16be",
"\x30\x42");
248 einval(
"euc-jp",
"\xA4\xA2\xA4",
"utf-16be",
"\x30\x42");
249 eilseq(
"euc-jp",
"\xA4\xA2\xFF\xFF",
"utf-16be",
"\x30\x42");
250 success(
"cp932",
"\x81\x60",
"iso-2022-jp",
"\x1B\x24\x42\x21\x41\x1B\x28\x42");
251 success(
"UTF-16BE",
"\xFF\x5E",
"iso-2022-jp",
"\x1B\x24\x42\x21\x41\x1B\x28\x42");
252 eilseq(
"UTF-16BE",
"\x30\x1C",
"iso-2022-jp//nocompat",
"");
253 success(
"UTF-16BE",
"\x30\x42\x30\x44",
"iso-2022-jp",
"\x1B\x24\x42\x24\x22\x24\x24\x1B\x28\x42");
254 success(
"iso-2022-jp",
"\x1B\x24\x42\x21\x41\x1B\x28\x42",
"UTF-16BE",
"\xFF\x5E");
255 }
256
257
258
259
260
261 eilseq(
"UTF-16BE",
"\xFF\x41",
"iso-8859-1",
"");
262 success(
"UTF-16BE",
"\xFF\x41",
"iso-8859-1//translit",
"a");
263
264
265
266
267
268 eilseq(
"UTF-16BE",
"\x30\x42",
"ascii",
"");
269 success(
"UTF-16BE",
"\x30\x42",
"ascii//translit",
"?");
270
271
272
273
274 eilseq(
"UTF-8",
"\xFF A \xFF B",
"ascii//ignore",
" A B");
275 eilseq(
"UTF-8",
"\xEF\xBC\xA1 A \xEF\xBC\xA2 B",
"ascii//ignore",
" A B");
276 eilseq(
"UTF-8",
"\xEF\x01 A \xEF\x02 B",
"ascii//ignore",
"\x01 A \x02 B");
277
278
279
280
281
282
283
284 return 0;
285}
#define success(from, fromstr, to, tostr)
#define einval(from, fromstr, to, tostr)
#define eilseq(from, fromstr, to, tostr)
int check_enc(const char *encname, int codepage)
◆ test()
Definition at line 90 of file win_iconv_test.c.
91{
94 char *pout;
95 size_t inbytesleft;
96 size_t outbytesleft;
99#ifdef USE_LIBICONV_DLL
101#endif
102
105 {
106 printf(
"%s -> %s: NG: INVALID ENCODING NAME: line=%d\n",
from, to,
line);
108 }
109
110#ifdef USE_LIBICONV_DLL
113
115 {
118 }
120 {
123 }
124#endif
125
127
128 pin = (
char *)fromstr;
129 pout = outbuf;
130 inbytesleft = fromsize;
132 r =
iconv(
cd, &
pin, &inbytesleft, &pout, &outbytesleft);
133 if (
r != (
size_t)(-1))
135 *pout = 0;
136
137#ifdef USE_LIBICONV_DLL
138 if (use_dll)
140#endif
147 else
148 {
149 printf(
"RESULT(%s:%s): ",
tohex(outbuf,
sizeof(outbuf) - outbytesleft),
153 }
154}
int strcmp(const char *String1, const char *String2)
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
GLdouble GLdouble GLdouble r
GLenum GLuint GLsizei bufsize
size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
const char * tohex(const char *str, int size)
const char * errstr(int errcode)
◆ tohex()
Definition at line 15 of file win_iconv_test.c.
16{
24}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Referenced by test().