From: "286000435 at qq dot com" <sourceware-bugzilla@sourceware.org>
To: libc-locales@sourceware.org
Subject: [Bug localedata/23502] gconv(GB18030 to UTF-8)
Date: Wed, 12 Sep 2018 08:55:00 -0000 [thread overview]
Message-ID: <bug-23502-716-n7UHb7kNyy@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-23502-716@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.
prev parent reply other threads:[~2018-09-12 8:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-10 10:26 [Bug localedata/23502] New: gconv(UTF-8 to GB18030) 286000435 at qq dot com
2018-08-10 10:29 ` [Bug localedata/23502] " 286000435 at qq dot com
2018-08-10 10:38 ` [Bug localedata/23502] gconv(GB18030 to UTF-8) 286000435 at qq dot com
2018-08-10 10:39 ` [Bug localedata/23502] gconv(UTF-8 to GB18030) 286000435 at qq dot com
2018-08-10 10:39 ` [Bug localedata/23502] gconv(GB18030 to UTF-8) 286000435 at qq dot com
2018-08-10 10:42 ` 286000435 at qq dot com
2018-08-10 12:04 ` schwab@linux-m68k.org
2018-09-05 14:04 ` schwab@linux-m68k.org
2018-09-12 8:55 ` 286000435 at qq dot com [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-23502-716-n7UHb7kNyy@http.sourceware.org/bugzilla/ \
--to=sourceware-bugzilla@sourceware.org \
--cc=libc-locales@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).