Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
glibc/iconvdata/bug-iconv1.c
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
40 lines (35 sloc)
1020 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Test program by Satoru Takabayashi. */ | |
#include <errno.h> | |
#include <iconv.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int | |
main (int argc, char **argv) | |
{ | |
const char in[] = "\x41\x42\x43\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa"; | |
/* valid eucJP string */ | |
const char exp[] = "\x41\x42\x43\x82\xa0\x82\xa2\x82\xa4"; | |
size_t outbufsize = 10; | |
/* 10 is too small to store full result (intentional) */ | |
size_t inleft, outleft; | |
char *in_p = (char *) in; | |
char out[outbufsize]; | |
char *out_p = out; | |
iconv_t cd; | |
int i; | |
inleft = strlen (in); | |
outleft = outbufsize; | |
cd = iconv_open ("SJIS", "eucJP"); | |
if (cd == (iconv_t) -1) | |
{ | |
puts ("iconv_open failed"); | |
exit (1); | |
} | |
iconv (cd, &in_p, &inleft, &out_p, &outleft); /* this returns E2BIG */ | |
for (i = 0; i < outbufsize - outleft; ++i) | |
printf (" %02x", (unsigned char) out[i]); | |
puts (""); | |
iconv_close (cd); | |
return outbufsize - outleft != 9 || memcmp (out, exp, 9) != 0; | |
} |