Back to index

glibc  2.9
Defines | Functions
tst-iconv3.c File Reference
#include <iconv.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>

Go to the source code of this file.


#define BUFSIZE   10000


int main (int argc, char *argv[])

Define Documentation

#define BUFSIZE   10000

Definition at line 8 of file tst-iconv3.c.

Function Documentation

int main ( int  argc,
char *  argv[] 

Definition at line 11 of file tst-iconv3.c.

  char inbuf[BUFSIZE];
  wchar_t outbuf[BUFSIZE];

  iconv_t cd;
  int i;
  char *inptr;
  char *outptr;
  size_t inbytes_left, outbytes_left;
  int count;
  int result = 0;

  for (i=0; i < BUFSIZE; i++)
    inbuf[i] = 'a';

  cd = iconv_open ("UCS-4LE", "UTF-8");

  inbytes_left = BUFSIZE;
  outbytes_left = BUFSIZE * 4;
  inptr = inbuf;
  outptr = (char *) outbuf;

  count = iconv (cd, &inptr, &inbytes_left, &outptr, &outbytes_left);

  if (count < 0)
      if (errno == E2BIG)
       printf ("Received E2BIG\n");
       printf ("Received something else\n");

      printf ("inptr change: %td\n", inptr - inbuf);
      printf ("inlen change: %zd\n", BUFSIZE - inbytes_left);
      printf ("outptr change: %td\n", outptr - (char *) outbuf);
      printf ("outlen change: %zd\n", BUFSIZE * 4 - outbytes_left);
      result = 1;
    printf ("Succeeded\n");

  return result;

Here is the call graph for this function: