bug-gnu-libiconv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gnu-libiconv] 3 char from UTF-8 to MacRoman iconv


From: jake
Subject: [bug-gnu-libiconv] 3 char from UTF-8 to MacRoman iconv
Date: Thu, 3 Jul 2008 11:59:33 -0400 (EDT)


-- attaching a copy of the original message for the archive --

Hello, Bruno:

While playing with libiconv 1.12 I noticed that it is unable
to convert the 3 particular characters from UTF8 to MACROMAN
(going from MACROMAN to UTF8 works fine). They are

CE A9       189 937     0xBD    U+03A9  &Omega
E2 82 AC    219 8364    0xDB    U+20AC  &euro
EF A3 BF    240 63743   0xF0    U+F8FF  Apple logo

Is this a known issue?


---> char[189]0xBD       2 bytes in UTF8                    omega
now converting back ... invalid char sequence
0 bytes in MACROMAN
---> char[219]0xDB       3 bytes in UTF8                    euro currency
now converting back ... invalid char sequence
0 bytes in MACROMAN
---> char[240]0xF0       3 bytes in UTF8                    apple logo
now converting back ... invalid char sequence
0 bytes in MACROMAN


Attached is the sample code which reproduces this error.

int main (int argc, const char * argv[])
{
     iconv_t     cd1;
     iconv_t     cd2;
     cd1 = iconv_open("UTF-8", "MACROMAN");
     cd2 = iconv_open("MACROMAN", "UTF-8");

     printf("converter loaded\n");

     unsigned char       a[8];
     unsigned char       b[8];
     unsigned char       c[8];
     char *      src;
     char *      dst;
     char *      dfront;

     size_t      slen;
     size_t      dlen;

     int         i,j;
     for (i = 0; i < 256; i++)
     {
         printf("\n---> char[%d]0x%X       ", i, i);
         memset(a, 0, 8);
         memset(b, 0, 8);
         memset(c, 0, 8);

         a[0] = (char) i;

         slen = 1;
         dlen = 8;

         src     = a;
         dst     = b;
         dfront  = b;

         printf("converting MACROMAN -> UTF8 ... ");

         if (iconv(cd1, &src, &slen, &dst, &dlen) == (size_t) -1)
         {
             if        (errno == E2BIG) {
                 printf("not enough space in dst\n");
             } else if (errno == EILSEQ) {
             printf("invalid char sequence\n");
             } else if (errno == EINVAL) {
                 printf("incomplete sequence\n");
             } else {
                 printf("uknown error\n");
             }
         }

         printf("%d bytes in UTF8\n", (dst - dfront));

         for (j = 0; j < 8; j++) printf("%2X ", a[j]);  printf("\n");
         for (j = 0; j < 8; j++) printf("%2X ", b[j]);  printf("\n");

         printf("now converting back UTF8 -> MACROMAN ... ");

         slen = (dst - dfront);
         dlen = 8;

         src     = b;
         dst     = c;
         dfront  = c;

         if (iconv(cd2, &src, &slen, &dst, &dlen) == (size_t) -1)
         {
             if        (errno == E2BIG) {
                 printf("not enough space in dst\n");
             } else if (errno == EILSEQ) {
             printf("invalid char sequence\n");
             } else if (errno == EINVAL) {
                 printf("incomplete sequence\n");
             } else {
                 printf("uknown error\n");
             }
         }

         printf("%d bytes in MACROMAN\n", (dst - dfront));
     }

     iconv_close(cd1);
     iconv_close(cd2);

     printf("exiting...\n");
}







reply via email to

[Prev in Thread] Current Thread [Next in Thread]