VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/shaderlib/libWineStub/include/wine/unicode.h@ 65619

Last change on this file since 65619 was 53201, checked in by vboxsync, 10 years ago

Devices/Main: vmsvga updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.6 KB
Line 
1/*
2 * Wine internal Unicode definitions
3 *
4 * Copyright 2000 Alexandre Julliard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21/*
22 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
23 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
24 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
25 * a choice of LGPL license versions is made available with the language indicating
26 * that LGPLv2 or any later version may be used, or where a choice of which version
27 * of the LGPL is applied is otherwise unspecified.
28 */
29
30#ifndef __WINE_WINE_UNICODE_H
31#define __WINE_WINE_UNICODE_H
32
33#include <stdarg.h>
34
35#include <windef.h>
36#include <winbase.h>
37#include <winnls.h>
38
39#ifdef __WINE_WINE_TEST_H
40#error This file should not be used in Wine tests
41#endif
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47#ifndef WINE_UNICODE_API
48# if defined(_MSC_VER) || defined(__MINGW32__)
49# define WINE_UNICODE_API DECLSPEC_IMPORT
50# else
51# define WINE_UNICODE_API
52# endif
53#endif
54
55/*#ifndef WINE_UNICODE_INLINE
56#define WINE_UNICODE_INLINE extern inline
57#endif*/
58#define WINE_UNICODE_INLINE static __inline
59
60/* code page info common to SBCS and DBCS */
61struct cp_info
62{
63 unsigned int codepage; /* codepage id */
64 unsigned int char_size; /* char size (1 or 2 bytes) */
65 WCHAR def_char; /* default char value (can be double-byte) */
66 WCHAR def_unicode_char; /* default Unicode char value */
67 const char *name; /* code page name */
68};
69
70struct sbcs_table
71{
72 struct cp_info info;
73 const WCHAR *cp2uni; /* code page -> Unicode map */
74 const WCHAR *cp2uni_glyphs; /* code page -> Unicode map with glyph chars */
75 const unsigned char *uni2cp_low; /* Unicode -> code page map */
76 const unsigned short *uni2cp_high;
77};
78
79struct dbcs_table
80{
81 struct cp_info info;
82 const WCHAR *cp2uni; /* code page -> Unicode map */
83 const unsigned char *cp2uni_leadbytes;
84 const unsigned short *uni2cp_low; /* Unicode -> code page map */
85 const unsigned short *uni2cp_high;
86 unsigned char lead_bytes[12]; /* lead bytes ranges */
87};
88
89union cptable
90{
91 struct cp_info info;
92 struct sbcs_table sbcs;
93 struct dbcs_table dbcs;
94};
95
96extern const union cptable *wine_cp_get_table( unsigned int codepage );
97extern const union cptable *wine_cp_enum_table( unsigned int index );
98
99extern int wine_cp_mbstowcs( const union cptable *table, int flags,
100 const char *src, int srclen,
101 WCHAR *dst, int dstlen );
102extern int wine_cp_wcstombs( const union cptable *table, int flags,
103 const WCHAR *src, int srclen,
104 char *dst, int dstlen, const char *defchar, int *used );
105extern int wine_cpsymbol_mbstowcs( const char *src, int srclen, WCHAR *dst, int dstlen );
106extern int wine_cpsymbol_wcstombs( const WCHAR *src, int srclen, char *dst, int dstlen );
107extern int wine_utf8_mbstowcs( int flags, const char *src, int srclen, WCHAR *dst, int dstlen );
108extern int wine_utf8_wcstombs( int flags, const WCHAR *src, int srclen, char *dst, int dstlen );
109
110extern int wine_compare_string( int flags, const WCHAR *str1, int len1, const WCHAR *str2, int len2 );
111extern int wine_get_sortkey( int flags, const WCHAR *src, int srclen, char *dst, int dstlen );
112extern int wine_fold_string( int flags, const WCHAR *src, int srclen , WCHAR *dst, int dstlen );
113
114extern int strcmpiW( const WCHAR *str1, const WCHAR *str2 );
115extern int strncmpiW( const WCHAR *str1, const WCHAR *str2, int n );
116extern int memicmpW( const WCHAR *str1, const WCHAR *str2, int n );
117extern WCHAR *strstrW( const WCHAR *str, const WCHAR *sub );
118extern long int strtolW( const WCHAR *nptr, WCHAR **endptr, int base );
119extern unsigned long int strtoulW( const WCHAR *nptr, WCHAR **endptr, int base );
120extern int sprintfW( WCHAR *str, const WCHAR *format, ... );
121extern int snprintfW( WCHAR *str, size_t len, const WCHAR *format, ... );
122extern int vsprintfW( WCHAR *str, const WCHAR *format, va_list valist );
123extern int vsnprintfW( WCHAR *str, size_t len, const WCHAR *format, va_list valist );
124
125#ifdef WINE_UNICODE_INLINE
126
127WINE_UNICODE_INLINE int wine_is_dbcs_leadbyte( const union cptable *table, unsigned char ch );
128WINE_UNICODE_INLINE int wine_is_dbcs_leadbyte( const union cptable *table, unsigned char ch )
129{
130 return (table->info.char_size == 2) && (table->dbcs.cp2uni_leadbytes[ch]);
131}
132
133WINE_UNICODE_INLINE WCHAR tolowerW( WCHAR ch );
134WINE_UNICODE_INLINE WCHAR tolowerW( WCHAR ch )
135{
136 extern WINE_UNICODE_API const WCHAR wine_casemap_lower[];
137 return ch + wine_casemap_lower[wine_casemap_lower[ch >> 8] + (ch & 0xff)];
138}
139
140WINE_UNICODE_INLINE WCHAR toupperW( WCHAR ch );
141WINE_UNICODE_INLINE WCHAR toupperW( WCHAR ch )
142{
143 extern WINE_UNICODE_API const WCHAR wine_casemap_upper[];
144 return ch + wine_casemap_upper[wine_casemap_upper[ch >> 8] + (ch & 0xff)];
145}
146
147/* the character type contains the C1_* flags in the low 12 bits */
148/* and the C2_* type in the high 4 bits */
149WINE_UNICODE_INLINE unsigned short get_char_typeW( WCHAR ch );
150WINE_UNICODE_INLINE unsigned short get_char_typeW( WCHAR ch )
151{
152 extern WINE_UNICODE_API const unsigned short wine_wctype_table[];
153 return wine_wctype_table[wine_wctype_table[ch >> 8] + (ch & 0xff)];
154}
155
156WINE_UNICODE_INLINE int iscntrlW( WCHAR wc );
157WINE_UNICODE_INLINE int iscntrlW( WCHAR wc )
158{
159 return get_char_typeW(wc) & C1_CNTRL;
160}
161
162WINE_UNICODE_INLINE int ispunctW( WCHAR wc );
163WINE_UNICODE_INLINE int ispunctW( WCHAR wc )
164{
165 return get_char_typeW(wc) & C1_PUNCT;
166}
167
168WINE_UNICODE_INLINE int isspaceW( WCHAR wc );
169WINE_UNICODE_INLINE int isspaceW( WCHAR wc )
170{
171 return get_char_typeW(wc) & C1_SPACE;
172}
173
174WINE_UNICODE_INLINE int isdigitW( WCHAR wc );
175WINE_UNICODE_INLINE int isdigitW( WCHAR wc )
176{
177 return get_char_typeW(wc) & C1_DIGIT;
178}
179
180WINE_UNICODE_INLINE int isxdigitW( WCHAR wc );
181WINE_UNICODE_INLINE int isxdigitW( WCHAR wc )
182{
183 return get_char_typeW(wc) & C1_XDIGIT;
184}
185
186WINE_UNICODE_INLINE int islowerW( WCHAR wc );
187WINE_UNICODE_INLINE int islowerW( WCHAR wc )
188{
189 return get_char_typeW(wc) & C1_LOWER;
190}
191
192WINE_UNICODE_INLINE int isupperW( WCHAR wc );
193WINE_UNICODE_INLINE int isupperW( WCHAR wc )
194{
195 return get_char_typeW(wc) & C1_UPPER;
196}
197
198WINE_UNICODE_INLINE int isalnumW( WCHAR wc );
199WINE_UNICODE_INLINE int isalnumW( WCHAR wc )
200{
201 return get_char_typeW(wc) & (C1_ALPHA|C1_DIGIT|C1_LOWER|C1_UPPER);
202}
203
204WINE_UNICODE_INLINE int isalphaW( WCHAR wc );
205WINE_UNICODE_INLINE int isalphaW( WCHAR wc )
206{
207 return get_char_typeW(wc) & (C1_ALPHA|C1_LOWER|C1_UPPER);
208}
209
210WINE_UNICODE_INLINE int isgraphW( WCHAR wc );
211WINE_UNICODE_INLINE int isgraphW( WCHAR wc )
212{
213 return get_char_typeW(wc) & (C1_ALPHA|C1_PUNCT|C1_DIGIT|C1_LOWER|C1_UPPER);
214}
215
216WINE_UNICODE_INLINE int isprintW( WCHAR wc );
217WINE_UNICODE_INLINE int isprintW( WCHAR wc )
218{
219 return get_char_typeW(wc) & (C1_ALPHA|C1_BLANK|C1_PUNCT|C1_DIGIT|C1_LOWER|C1_UPPER);
220}
221
222/* some useful string manipulation routines */
223
224WINE_UNICODE_INLINE unsigned int strlenW( const WCHAR *str );
225WINE_UNICODE_INLINE unsigned int strlenW( const WCHAR *str )
226{
227 const WCHAR *s = str;
228 while (*s) s++;
229 return s - str;
230}
231
232WINE_UNICODE_INLINE WCHAR *strcpyW( WCHAR *dst, const WCHAR *src );
233WINE_UNICODE_INLINE WCHAR *strcpyW( WCHAR *dst, const WCHAR *src )
234{
235 WCHAR *p = dst;
236 while ((*p++ = *src++));
237 return dst;
238}
239
240/* strncpy doesn't do what you think, don't use it */
241#define strncpyW(d,s,n) error do_not_use_strncpyW_use_lstrcpynW_or_memcpy_instead
242
243WINE_UNICODE_INLINE int strcmpW( const WCHAR *str1, const WCHAR *str2 );
244WINE_UNICODE_INLINE int strcmpW( const WCHAR *str1, const WCHAR *str2 )
245{
246 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
247 return *str1 - *str2;
248}
249
250WINE_UNICODE_INLINE int strncmpW( const WCHAR *str1, const WCHAR *str2, int n );
251WINE_UNICODE_INLINE int strncmpW( const WCHAR *str1, const WCHAR *str2, int n )
252{
253 if (n <= 0) return 0;
254 while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
255 return *str1 - *str2;
256}
257
258WINE_UNICODE_INLINE WCHAR *strcatW( WCHAR *dst, const WCHAR *src );
259WINE_UNICODE_INLINE WCHAR *strcatW( WCHAR *dst, const WCHAR *src )
260{
261 strcpyW( dst + strlenW(dst), src );
262 return dst;
263}
264
265WINE_UNICODE_INLINE WCHAR *strchrW( const WCHAR *str, WCHAR ch );
266WINE_UNICODE_INLINE WCHAR *strchrW( const WCHAR *str, WCHAR ch )
267{
268 do { if (*str == ch) return (WCHAR *)(ULONG_PTR)str; } while (*str++);
269 return NULL;
270}
271
272WINE_UNICODE_INLINE WCHAR *strrchrW( const WCHAR *str, WCHAR ch );
273WINE_UNICODE_INLINE WCHAR *strrchrW( const WCHAR *str, WCHAR ch )
274{
275 WCHAR *ret = NULL;
276 do { if (*str == ch) ret = (WCHAR *)(ULONG_PTR)str; } while (*str++);
277 return ret;
278}
279
280WINE_UNICODE_INLINE WCHAR *strpbrkW( const WCHAR *str, const WCHAR *accept );
281WINE_UNICODE_INLINE WCHAR *strpbrkW( const WCHAR *str, const WCHAR *accept )
282{
283 for ( ; *str; str++) if (strchrW( accept, *str )) return (WCHAR *)(ULONG_PTR)str;
284 return NULL;
285}
286
287WINE_UNICODE_INLINE size_t strspnW( const WCHAR *str, const WCHAR *accept );
288WINE_UNICODE_INLINE size_t strspnW( const WCHAR *str, const WCHAR *accept )
289{
290 const WCHAR *ptr;
291 for (ptr = str; *ptr; ptr++) if (!strchrW( accept, *ptr )) break;
292 return ptr - str;
293}
294
295WINE_UNICODE_INLINE size_t strcspnW( const WCHAR *str, const WCHAR *reject );
296WINE_UNICODE_INLINE size_t strcspnW( const WCHAR *str, const WCHAR *reject )
297{
298 const WCHAR *ptr;
299 for (ptr = str; *ptr; ptr++) if (strchrW( reject, *ptr )) break;
300 return ptr - str;
301}
302
303WINE_UNICODE_INLINE WCHAR *strlwrW( WCHAR *str );
304WINE_UNICODE_INLINE WCHAR *strlwrW( WCHAR *str )
305{
306 WCHAR *ret = str;
307 while ((*str = tolowerW(*str))) str++;
308 return ret;
309}
310
311WINE_UNICODE_INLINE WCHAR *struprW( WCHAR *str );
312WINE_UNICODE_INLINE WCHAR *struprW( WCHAR *str )
313{
314 WCHAR *ret = str;
315 while ((*str = toupperW(*str))) str++;
316 return ret;
317}
318
319WINE_UNICODE_INLINE WCHAR *memchrW( const WCHAR *ptr, WCHAR ch, size_t n );
320WINE_UNICODE_INLINE WCHAR *memchrW( const WCHAR *ptr, WCHAR ch, size_t n )
321{
322 const WCHAR *end;
323 for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) return (WCHAR *)(ULONG_PTR)ptr;
324 return NULL;
325}
326
327WINE_UNICODE_INLINE WCHAR *memrchrW( const WCHAR *ptr, WCHAR ch, size_t n );
328WINE_UNICODE_INLINE WCHAR *memrchrW( const WCHAR *ptr, WCHAR ch, size_t n )
329{
330 const WCHAR *end;
331 WCHAR *ret = NULL;
332 for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) ret = (WCHAR *)(ULONG_PTR)ptr;
333 return ret;
334}
335
336WINE_UNICODE_INLINE long int atolW( const WCHAR *str );
337WINE_UNICODE_INLINE long int atolW( const WCHAR *str )
338{
339 return strtolW( str, (WCHAR **)0, 10 );
340}
341
342WINE_UNICODE_INLINE int atoiW( const WCHAR *str );
343WINE_UNICODE_INLINE int atoiW( const WCHAR *str )
344{
345 return (int)atolW( str );
346}
347#endif //#ifdef WINE_UNICODE_INLINE
348
349#undef WINE_UNICODE_INLINE
350
351#ifdef __cplusplus
352}
353#endif
354
355#endif /* __WINE_WINE_UNICODE_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette