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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
/*
* libzvbi test
*
* Copyright (C) 2000, 2001 Michael H. Schimek
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: unicode.c,v 1.3 2002/02/10 11:47:10 mschimek Exp $ */
#undef NDEBUG
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <libzvbi.h>
extern unsigned int vbi_teletext_unicode(int, int, int);
extern unsigned int vbi_teletext_composed_unicode(unsigned int a, unsigned int c);
extern unsigned int vbi_caption_unicode(unsigned int c);
static void
putwchar(int c)
{
if (c < 0x80) {
putchar (c);
} else if (c < 0x800) {
putchar (0xC0 | (c >> 6));
putchar (0x80 | (c & 0x3F));
} else if (c < 0x10000) {
putchar (0xE0 | (c >> 12));
putchar (0x80 | ((c >> 6) & 0x3F));
putchar (0x80 | (c & 0x3F));
} else if (c < 0x200000) {
putchar (0xF0 | (c >> 18));
putchar (0x80 | ((c >> 12) & 0x3F));
putchar (0x80 | ((c >> 6) & 0x3F));
putchar (0x80 | (c & 0x3F));
}
}
static void
putwstr(unsigned char *s)
{
for (; *s; s++)
putwchar(*s);
}
static unsigned char
national[] = {
0x23, 0x24, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
0x60, 0x7B, 0x7C, 0x7D, 0x7E
};
static void
print_set(char *name, int s)
{
int i, j;
putwstr(name);
putwchar('\n');
putwchar('\n');
for (i = 0; i < 16; i++) {
for (j = 2; j < 8; j++) {
putwchar(vbi_teletext_unicode(s, 0, j * 16 + i));
putwchar(' ');
}
putwchar('\n');
}
putwchar('\n');
}
int
main(int argc, char **argv)
{
int i, j;
putwstr("libzvbi unicode test -*- coding: utf-8 -*-\n\n");
putwstr("ETS 300 706 Table 36: Latin National Option Sub-sets\n\n");
for (i = 1; i < 14; i++) {
for (j = 0; j < sizeof(national) / sizeof(national[0]); j++) {
putwchar(vbi_teletext_unicode(1, i, national[j]));
putwchar(' ');
}
putwchar('\n');
}
putwchar('\n');
print_set("ETS 300 706 Table 35: Latin G0 Primary Set\n", 1);
print_set("ETS 300 706 Table 37: Latin G2 Supplementary Set\n", 2);
print_set("ETS 300 706 Table 38: Cyrillic G0 Primary Set - Option 1 - Serbian/Croatian\n", 3);
print_set("ETS 300 706 Table 39: Cyrillic G0 Primary Set - Option 2 - Russian/Bulgarian\n", 4);
print_set("ETS 300 706 Table 40: Cyrillic G0 Primary Set - Option 3 - Ukrainian\n", 5);
print_set("ETS 300 706 Table 41: Cyrillic G2 Supplementary Set\n", 6);
print_set("ETS 300 706 Table 42: Greek G0 Primary Set\n", 7);
print_set("ETS 300 706 Table 43: Greek G2 Supplementary Set\n", 8);
print_set("ETS 300 706 Table 44: Arabic G0 Primary Set\n", 9);
print_set("ETS 300 706 Table 45: Arabic G2 Supplementary Set\n", 10);
print_set("ETS 300 706 Table 46: Hebrew G0 Primary Set\n", 11);
putwstr("ETS 300 706 Table 47: G1 Block Mosaics Set\n\n");
for (i = 0; i < 16; i++) {
for (j = 2; j < 8; j++) {
if (j == 4 || j == 5)
putwchar(' ');
else
putwchar(vbi_teletext_unicode(12, 0, j * 16 + i));
putwchar(' ');
}
putwchar('\n');
}
putwchar('\n');
print_set("ETS 300 706 Table 48: G3 Smooth Mosaics and Line Drawing Set\n", 13);
putwstr("Teletext composed glyphs\n\n ");
for (i = 0x40; i < 0x60; i++)
putwchar(vbi_teletext_unicode(1, 0, i));
putwstr("\n\n");
for (i = 0; i < 16; i++) {
putwchar(vbi_teletext_unicode(2, 0, 0x40 + i));
putwstr(" ");
for (j = 0x40; j < 0x60; j++) {
unsigned int c = vbi_teletext_composed_unicode(i, j);
putwchar((c == 0) ? '-' : c);
}
putwchar('\n');
}
putwchar('\n');
putwstr("Teletext composed glyphs\n\n ");
for (i = 0x60; i < 0x80; i++)
putwchar(vbi_teletext_unicode(1, 0, i));
putwstr("\n\n");
for (i = 0; i < 16; i++) {
putwchar(vbi_teletext_unicode(2, 0, 0x40 + i));
putwstr(" ");
for (j = 0x60; j < 0x80; j++) {
unsigned int c = vbi_teletext_composed_unicode(i, j);
putwchar((c == 0) ? '-' : c);
}
putwchar('\n');
}
putwchar('\n');
putwstr("EIA 608 Closed Captioning Basic Character Set\n\n");
for (i = 0; i < 8; i++) {
for (j = 0x20; j < 0x80; j += 8) {
putwchar(vbi_caption_unicode(j + i));
putwchar(' ');
}
putwchar('\n');
}
putwchar('\n');
putwstr("EIA 608 Closed Captioning Special Characters\n\n");
for (i = 0; i < 16; i++) {
putwchar(vbi_caption_unicode(i));
}
putwchar('\n');
exit(EXIT_SUCCESS);
}
|