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 
27 namespace 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  */
38 extern int utf8_getc(const char *s);
39 extern int utf8_getx(char **s);
40 extern int utf8_setc(char *s, int c);
41 extern int utf8_width(const char *s);
42 extern int utf8_cwidth(int c);
43 extern int utf8_isok(int c);
44 
48 extern int ascii_getc(const char *s);
49 extern int ascii_getx(char **s);
50 extern int ascii_setc(char *s, int c);
51 extern int ascii_width(const char *s);
52 extern int ascii_cwidth(int c);
53 extern int ascii_isok(int c);
54 
55 /* ugetc: */
56 extern int (*ugetc)(const char *s);
57 /* ugetxc: */
58 extern int (*ugetx)(char **s);
59 /* ugetxc: */
60 extern int (*ugetxc)(const char * const *s);
61 /* usetc: */
62 extern int (*usetc)(char *s, int c);
63 /* uwidth: */
64 extern int (*uwidth)(const char *s);
65 /* ucwidth: */
66 extern int (*ucwidth)(int c);
67 /* uisok: */
68 extern int (*uisok)(int c);
69 
70 /* set_uformat:
71  * Selects a new text encoding format.
72  */
73 extern void set_uformat(int type);
74 
75 enum { LC_CTYPE };
76 extern const char *setlocale(int type, const char *language);
77 
78 /* get_uformat:
79  * Returns the current text encoding format.
80  */
81 extern int get_uformat();
82 extern size_t ustrsize(const char *s);
83 /* &nicode string length
84  */
85 extern int ustrlen(const char *s);
86 /* utolower:
87  * Unicode-aware version of the ANSI tolower() function.
88  */
89 extern int utolower(int c);
90 /* utoupper:
91  * Unicode-aware version of the ANSI toupper() function.
92  */
93 extern int utoupper(int c);
94 /* Unicode string compare
95  */
96 extern int ustrcmp(const char *s1, const char *s2);
97  /* ustricmp:
98  * Unicode-aware version of the DJGPP stricmp() function.
99  */
100 extern int ustricmp(const char *s1, const char *s2);
101 /* ustrncmp:
102  * Unicode-aware version of the ANSI strncmp() function.
103  */
104 extern int ustrncmp(const char *s1, const char *s2, int n);
105 /* ustrnicmp:
106  * Unicode-aware version of the DJGPP strnicmp() function.
107  */
108 extern 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  */
115 extern int uoffset(const char *s, int index);
116 
117 /* ugetat:
118  * Returns the character from the specified index within the string.
119  */
120 extern int ugetat(const char *s, int idx);
121 
122 /* ustrlwr:
123  * Unicode-aware version of the ANSI strlwr() function.
124  */
125 extern char *ustrlwr(char *s);
126 /* ustrupr:
127  * Unicode-aware version of the ANSI strupr() function.
128  */
129 extern char *ustrupr(char *s);
130 /* ustrstr:
131  * Unicode-aware version of the ANSI strstr() function.
132  */
133 extern 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  */
139 int 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  */
144 extern int ustrsizez(const char *s);
145 
146 extern int need_uconvert(const char *s, int type, int newtype);
147 extern int uvszprintf(char *buf, int size, const char *format, va_list args);
148 
149 } // namespace AGS3
150 
151 #endif
Definition: ags.h:40