File: unicode.c

package info (click to toggle)
aoeui 1.4-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 440 kB
  • ctags: 574
  • sloc: ansic: 6,005; makefile: 76; sh: 11
file content (32 lines) | stat: -rw-r--r-- 632 bytes parent folder | download | duplicates (5)
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
28
29
30
31
32
/* Copyright 2007, 2008 Peter Klausler.  See COPYING for license. */
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "types.h"
#include "utf8.h"

int main(int argc, const char *argv[])
{
	Unicode_t ch = 0x203b;
	unsigned 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[unicode_utf8(buf, ch++)] = '\0';
		printf("\t%s", buf);
		if (++at == 8) {
			at = 0;
			putchar('\n');
		}
	}
	if (at)
		putchar('\n');
	return EXIT_SUCCESS;
}