Debian Codegraph @

texk/gregorio/gregorio-src/src/unicode.h

raw
1 /*
2 * Gregorio is a program that translates gabc files to GregorioTeX
3 * This header prototypes the UTF-8 support functions.
4 *
5 * Copyright (C) 2008-2025 The Gregorio Project (see CONTRIBUTORS.md)
6 *
7 * This file is part of Gregorio.
8 *
9 * Gregorio is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * Gregorio is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with Gregorio. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #ifndef UNICODE_H_FIRST_PART
24 #define UNICODE_H_FIRST_PART
25 #define UNICODE_H
26
27 #include <stdio.h>
28 #ifdef HAVE_STDINT_H
29 #include <stdint.h>
30 #else
31 #include <inttypes.h>
32 #endif
33
34 typedef uint32_t grewchar;
35
36 void gregorio_print_unichar(FILE *f, grewchar to_print);
37 void gregorio_print_unistring(FILE *f, const grewchar *first_char);
38 grewchar *gregorio_build_grewchar_string_from_buf(const char *buf);
39
40 static __inline size_t gregorio_wcstrlen(const grewchar *wstr)
41 {
42 size_t length = 0;
43
44 while (*(wstr++)) {
45 ++length;
46 }
47
48 return length;
49 }
50
51 /* this macro is for portability under windows, where L'x' is only two-bytes
52 * long, and thus needs to be cast to a 4-bytes integer. */
53 #define GL(wc) ((const grewchar) L'wc')
54
55 #endif
56
57 /* we enter the second part only if struct.h has already been included, because
58 * we need gregorio_character */
59
60 #ifdef STRUCT_H
61
62 #ifndef UNICODE_H_SECOND_PART
63 #define UNICODE_H_SECOND_PART
64
65 gregorio_character *gregorio_build_char_list_from_buf(const char *buf);
66
67 #endif
68
69 #endif