This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug localedata/23502] gconv(GB18030 to UTF-8)
- From: "286000435 at qq dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Wed, 12 Sep 2018 08:55:06 +0000
- Subject: [Bug localedata/23502] gconv(GB18030 to UTF-8)
- Auto-submitted: auto-generated
- References: <bug-23502-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=23502
--- Comment #3 from lance <286000435 at qq dot com> ---
(In reply to Andreas Schwab from comment #2)
> What is the exact contents of the array s?
This is new code:
#include <iconv.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void print_buf(char* buf, size_t len)
{
size_t i;
for (i = 0; i < len; ++i) {
printf("%02X ", (unsigned char)buf[i]);
}
printf("\n");
}
int main(int argc, char** argv)
{
char s[] = "早見純";
print_buf(s, sizeof(s));
iconv_t cd = iconv_open("GB18030", "UTF-8");
if (cd <= 0 ) {
printf("iconv_open fail\n");
return 0;
}
size_t inbytesleft = sizeof(s) - 1;
char dst[6 * sizeof(s)] = { 0 };
size_t outbytesleft = sizeof(dst) - 1;
char* inbuf = s;
char* outbuf = dst;
if (iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft) ==
(size_t)-1) {
printf("iconv fail: %d\n", errno);
}
iconv_close(cd);
size_t n = strlen(dst);
printf("inbytesleft: %u, outbytesleft: %u, dst len: %u\n", inbytesleft,
outbytesleft, n);
print_buf(dst, n);
return 0;
}
array s contents is :
E6 97 A9 E8 A6 8B E7 B4 94 EE A0 97 00
--
You are receiving this mail because:
You are on the CC list for the bug.