I'm trying to use the iconv that's in FreeBSD-CURRENT and it's not reporting 
errors the way I expect.  To demonstrate, here's a test program that tries to 
convert UTF-8 to KOI8-R.  This should report an error, since the UTF-8 string 
here "ĐÒÉ×ÅÔ" contains characters not available in KOI8-R.

On FreeBSD-CURRENT (updated yesterday), the iconv() call returns 0, consumes 
the entire input, and generates 9 characters "D`O'ExA^O".  I believe that the 
call should return 6 in this case, since each of the six input characters were 
converted to "non-identical" characters in the output.

The term "non-identical" is used in the return value description of:

For comparison, I tried this on MacOS, where the iconv() call returns -1, 
consumes no input, and generates no output.

#include <iconv.h>
#include <stdio.h>
#include <string.h>

main(int argc, char **argv)
  const char *input = "\303\220\303\222\303\211\303\227\303\205\303\224";
  const char *in = input;
  size_t insize = strlen(in);
  char outbuff[64];
  char *out = outbuff;
  size_t outsize = sizeof(outbuff);
  iconv_t cd = iconv_open("KOI8-R", "UTF-8");
  size_t s = iconv(cd, &in, &insize, &out, &outsize);
  *out = '\0';

  printf("s = %d\n", (int)s);
  printf("insize = %d\n", (int)insize);
  printf("outsize = %d\n", (int)outsize);
  printf("%s", outbuff);
  return (0);

freebsd-current@freebsd.org mailing list
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to