libxconv/test.c
2017-03-09 14:55:16 +00:00

67 lines
876 B
C

#include <stdio.h>
#include <string.h>
#include "charset.h"
char *teststr[] = {
"The House That \243100k Built",
"home d\302ecor",
"home made p\303at\302e",
"scene at \251Odette\271 that",
NULL
};
static void
hexdump(uint8_t *s, uint32_t len)
{
uint16_t off;
if (!s)
return;
if (!len)
len = strlen((char *)s);
for (off = 0; off < len; off += 16)
{
uint32_t i;
printf("%08lx: ", (unsigned long)off);
for (i = off; i - off < 16; i++)
{
if (i < len)
printf("%02x ", s[i] & 0xff);
else
printf(" ");
}
printf(" ");
for (i = off; i < len && i - off < 16; i++)
printf("%c", isprint((int)s[i]) ? s[i] : '.');
printf("\n");
}
}
int
main()
{
char buf[0x200];
int i;
for (i = 0; teststr[i]; i++)
{
hexdump(teststr[i], 0);
xconv(teststr[i], buf, sizeof(buf));
hexdump(buf, 0);
printf("\n\n");
}
return 0;
}