-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathucdn-test.c
69 lines (58 loc) · 2.46 KB
/
ucdn-test.c
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
/*
* Copyright (C) 2012 Grigori Goronzy <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include "ucdn.h"
int main(int argc, char **argv)
{
uint32_t codepoint, a, b;
int i, len;
uint32_t decomposed[18];
if (argc < 2)
return EXIT_FAILURE;
codepoint = (uint32_t)strtol(argv[1], NULL, 0);
printf("codepoint U+%04X\n", codepoint);
printf("combining_class %d\n", ucdn_get_combining_class(codepoint));
printf("general_category %d\n", ucdn_get_general_category(codepoint));
if (ucdn_get_mirrored(codepoint))
printf("mirrored U+%04X\n", ucdn_mirror(codepoint));
switch(ucdn_paired_bracket_type(codepoint)) {
case UCDN_BIDI_PAIRED_BRACKET_TYPE_NONE:
break;
default:
if (ucdn_paired_bracket_type(codepoint) == UCDN_BIDI_PAIRED_BRACKET_TYPE_OPEN)
printf("paired bracket type open\n");
else
printf("paired bracket type close\n");
printf("paired bracket U+%04X\n", ucdn_paired_bracket(codepoint));
}
printf("eastasian_width %d\n", ucdn_get_east_asian_width(codepoint));
printf("script %d\n", ucdn_get_script(codepoint));
printf("linebreak_class %d\n", ucdn_get_linebreak_class(codepoint));
printf("bidi_class %d\n", ucdn_get_bidi_class(codepoint));
if ((len = ucdn_compat_decompose(codepoint, decomposed))) {
printf("compatibility_decomposition");
for (i = 0; i < len; i++) {
printf(" U+%04X", decomposed[i]);
}
printf("\n");
}
if (ucdn_decompose(codepoint, &a, &b))
printf("decomposition U+%04X U+%04X\n", a, b);
if (ucdn_compose(&codepoint, a, b))
printf("recomposition U+%04X\n", codepoint);
return EXIT_SUCCESS;
}