ScummVM API documentation
unicode.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef AGS_LIB_ALLEGRO_UNICODE_H
23#define AGS_LIB_ALLEGRO_UNICODE_H
24
25#include "ags/lib/allegro/base.h"
26
27namespace AGS3 {
28
29#define U_ASCII AL_ID('A','S','C','8')
30#define U_ASCII_CP AL_ID('A','S','C','P')
31#define U_UNICODE AL_ID('U','N','I','C')
32#define U_UTF8 AL_ID('U','T','F','8')
33#define U_CURRENT AL_ID('c','u','r','.')
34
35
36/* UTF-8 support functions
37 */
38extern int utf8_getc(const char *s);
39extern int utf8_getx(char **s);
40extern int utf8_setc(char *s, int c);
41extern int utf8_width(const char *s);
42extern int utf8_cwidth(int c);
43extern int utf8_isok(int c);
44
48extern int ascii_getc(const char *s);
49extern int ascii_getx(char **s);
50extern int ascii_setc(char *s, int c);
51extern int ascii_width(const char *s);
52extern int ascii_cwidth(int c);
53extern int ascii_isok(int c);
54
55/* ugetc: */
56extern int (*ugetc)(const char *s);
57/* ugetxc: */
58extern int (*ugetx)(char **s);
59/* ugetxc: */
60extern int (*ugetxc)(const char * const *s);
61/* usetc: */
62extern int (*usetc)(char *s, int c);
63/* uwidth: */
64extern int (*uwidth)(const char *s);
65/* ucwidth: */
66extern int (*ucwidth)(int c);
67/* uisok: */
68extern int (*uisok)(int c);
69
70/* set_uformat:
71 * Selects a new text encoding format.
72 */
73extern void set_uformat(int type);
74
75enum { LC_CTYPE };
76extern const char *setlocale(int type, const char *language);
77
78/* get_uformat:
79 * Returns the current text encoding format.
80 */
81extern int get_uformat();
82extern size_t ustrsize(const char *s);
83/* &nicode string length
84 */
85extern int ustrlen(const char *s);
86/* utolower:
87 * Unicode-aware version of the ANSI tolower() function.
88 */
89extern int utolower(int c);
90/* utoupper:
91 * Unicode-aware version of the ANSI toupper() function.
92 */
93extern int utoupper(int c);
94/* Unicode string compare
95 */
96extern int ustrcmp(const char *s1, const char *s2);
97 /* ustricmp:
98 * Unicode-aware version of the DJGPP stricmp() function.
99 */
100extern int ustricmp(const char *s1, const char *s2);
101/* ustrncmp:
102 * Unicode-aware version of the ANSI strncmp() function.
103 */
104extern int ustrncmp(const char *s1, const char *s2, int n);
105/* ustrnicmp:
106 * Unicode-aware version of the DJGPP strnicmp() function.
107 */
108extern int ustrnicmp(const char *s1, const char *s2, int n);
109/* uoffset:
110 * Returns the offset in bytes from the start of the string to the
111 * character at the specified index. If the index is negative, counts
112 * backward from the end of the string (-1 returns an offset to the
113 * last character).
114 */
115extern int uoffset(const char *s, int index);
116
117/* ugetat:
118 * Returns the character from the specified index within the string.
119 */
120extern int ugetat(const char *s, int idx);
121
122/* ustrlwr:
123 * Unicode-aware version of the ANSI strlwr() function.
124 */
125extern char *ustrlwr(char *s);
126/* ustrupr:
127 * Unicode-aware version of the ANSI strupr() function.
128 */
129extern char *ustrupr(char *s);
130/* ustrstr:
131 * Unicode-aware version of the ANSI strstr() function.
132 */
133extern const char *ustrstr(const char *s1, const char *s2);
134/* usetat:
135 * Modifies the character at the specified index within the string,
136 * handling adjustments for variable width data. Returns how far the
137 * rest of the string was moved.
138 */
139int usetat(char *s, int index, int c);
140/* ustrsizez:
141 * Returns the size of the specified string in bytes, including the
142 * trailing zero.
143 */
144extern int ustrsizez(const char *s);
145
146extern int need_uconvert(const char *s, int type, int newtype);
147extern int uvszprintf(char *buf, int size, const char *format, va_list args);
148
149} // namespace AGS3
150
151#endif