File: unicode.c

package info (click to toggle)
aoeui 1.1.1-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 348 kB
  • ctags: 487
  • sloc: ansic: 5,248; makefile: 67
file content (27 lines) | stat: -rw-r--r-- 489 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "utf8.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main(int argc, const char *argv[])
{
	unsigned ch = 0x203b, num = 1, at = 0;
	char buf[8];
	if (argc > 1)
		ch = strtoul(argv[1], NULL, 16);
	if (argc > 2)
		num = strtoul(argv[2], NULL, 0);
	while (num--) {
		if (!at)
			printf("0x%04x", ch);
		buf[utf8_out(buf, ch++)] = '\0';
		printf("\t%s", buf);
		if (++at == 8) {
			at = 0;
			putchar('\n');
		}
	}
	if (at)
		putchar('\n');
	return EXIT_SUCCESS;
}