root a970695
#include <stdio.h>
root a970695
#include <uniconv.h>
root a970695
#include <sys/types.h>
root a970695
#include <sys/stat.h>
root a970695
#include <fcntl.h>
root a970695
#include <string.h>
root a970695
#include <unistd.h>
root a970695
root a970695
int
root a970695
main (int argc, char **argv)
root a970695
{
root a970695
        if (argc < 2) {
root a970695
                printf ("Usage: %s \n", argv[0]);
root a970695
                return 1;
root a970695
        }
root a970695
root a970695
        size_t len8, len16, len32;
root a970695
        const char newline = '\n';
root a970695
root a970695
        uint8_t *res8 = u8_conv_from_encoding ("ASCII", iconveh_question_mark, argv[1], strlen (argv[1]), NULL, NULL, &len8);
root a970695
        uint16_t *res16 = u16_conv_from_encoding ("ASCII", iconveh_question_mark, argv[1], strlen (argv[1]), NULL, NULL, &len16);
root a970695
        uint32_t *res32 = u32_conv_from_encoding ("ASCII", iconveh_question_mark, argv[1], strlen (argv[1]), NULL, NULL, &len32);
root a970695
root a970695
        int fd = open ("testfile.in", O_WRONLY | O_CREAT, S_IRUSR);
root a970695
root a970695
        for (int i = 0; i < len8; i++)
root a970695
                write (fd, &res8[i], sizeof (uint8_t));
root a970695
        write (fd, &newline, 1);
root a970695
        for (int i = 0; i < len16; i++)
root a970695
                write (fd, &res16[i], sizeof (uint16_t));
root a970695
        write (fd, &newline, 1);
root a970695
        for (int i = 0; i < len32; i++)
root a970695
                write (fd, &res32[i], sizeof (uint32_t));
root a970695
root a970695
        close (fd);
root a970695
}
root a970695