286000435 at qq dot com
2018-08-10 04:56:27 UTC
https://sourceware.org/bugzilla/show_bug.cgi?id=23502
Bug ID: 23502
Summary: gconv(UTF-8 to GB18030)
Product: glibc
Version: 2.17
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: localedata
Assignee: unassigned at sourceware dot org
Reporter: 286000435 at qq dot com
CC: libc-locales at sourceware dot org
Target Milestone: ---
A bug of gconv(UTF-8 to GB18030).
The version of glibc is greater than 2.17(>=2.17).
Following code can't get the right result.
#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[] = "早見純";
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;
}
get error output:
iconv fail: 84
inbytesleft: 4, outbytesleft: 72, dst len: 6
D4 E7 D2 8A BC 83
But I can get the right result with gblic 2.12:
inbytesleft: 0, outbytesleft: 69, dst len: 8
D4 E7 D2 8A BC 83 FE 52
Bug ID: 23502
Summary: gconv(UTF-8 to GB18030)
Product: glibc
Version: 2.17
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: localedata
Assignee: unassigned at sourceware dot org
Reporter: 286000435 at qq dot com
CC: libc-locales at sourceware dot org
Target Milestone: ---
A bug of gconv(UTF-8 to GB18030).
The version of glibc is greater than 2.17(>=2.17).
Following code can't get the right result.
#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[] = "早見純";
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;
}
get error output:
iconv fail: 84
inbytesleft: 4, outbytesleft: 72, dst len: 6
D4 E7 D2 8A BC 83
But I can get the right result with gblic 2.12:
inbytesleft: 0, outbytesleft: 69, dst len: 8
D4 E7 D2 8A BC 83 FE 52
--
You are receiving this mail because:
You are on the CC list for the bug.
You are receiving this mail because:
You are on the CC list for the bug.