ReactOS 0.4.16-dev-297-gc569aee
unicode.h File Reference
#include <ctype.h>
#include <stdarg.h>
#include <string.h>
#include <typedefs.h>
Include dependency graph for unicode.h:

Go to the source code of this file.

Classes

struct  cp_info
 
struct  sbcs_table
 
struct  dbcs_table
 
union  cptable
 

Macros

#define C1_UPPER   1
 
#define C1_LOWER   2
 
#define C1_DIGIT   4
 
#define C1_SPACE   8
 
#define C1_PUNCT   16
 
#define C1_CNTRL   32
 
#define C1_BLANK   64
 
#define C1_XDIGIT   128
 
#define C1_ALPHA   256
 
#define MB_COMPOSITE   2
 
#define MB_ERR_INVALID_CHARS   8
 
#define MB_USEGLYPHCHARS   0x04
 
#define WC_COMPOSITECHECK   512
 
#define WC_DISCARDNS   16
 
#define WC_DEFAULTCHAR   64
 
#define WC_NO_BEST_FIT_CHARS   1024
 
#define WC_ERR_INVALID_CHARS   0x0080
 
#define WINE_UNICODE_API
 
#define WINE_UNICODE_INLINE   static inline
 
#define strncpyW(d, s, n)   error do_not_use_strncpyW_use_lstrcpynW_or_memcpy_instead
 

Functions

const union cptablewine_cp_get_table (unsigned int codepage)
 
const union cptablewine_cp_enum_table (unsigned int index)
 
int wine_cp_mbstowcs (const union cptable *table, int flags, const char *src, int srclen, WCHAR *dst, int dstlen)
 
int wine_cp_wcstombs (const union cptable *table, int flags, const WCHAR *src, int srclen, char *dst, int dstlen, const char *defchar, int *used)
 
int wine_cpsymbol_mbstowcs (const char *src, int srclen, WCHAR *dst, int dstlen)
 
int wine_cpsymbol_wcstombs (const WCHAR *src, int srclen, char *dst, int dstlen)
 
int wine_utf8_mbstowcs (int flags, const char *src, int srclen, WCHAR *dst, int dstlen)
 
int wine_utf8_wcstombs (int flags, const WCHAR *src, int srclen, char *dst, int dstlen)
 
int wine_compare_string (int flags, const WCHAR *str1, int len1, const WCHAR *str2, int len2)
 
int wine_get_sortkey (int flags, const WCHAR *src, int srclen, char *dst, int dstlen)
 
int wine_fold_string (int flags, const WCHAR *src, int srclen, WCHAR *dst, int dstlen)
 
int strcmpiW (const WCHAR *str1, const WCHAR *str2)
 
int strncmpiW (const WCHAR *str1, const WCHAR *str2, int n)
 
int memicmpW (const WCHAR *str1, const WCHAR *str2, int n)
 
WCHARstrstrW (const WCHAR *str, const WCHAR *sub)
 
long int strtolW (const WCHAR *nptr, WCHAR **endptr, int base)
 
unsigned long int strtoulW (const WCHAR *nptr, WCHAR **endptr, int base)
 
int sprintfW (WCHAR *str, const WCHAR *format,...)
 
int snprintfW (WCHAR *str, size_t len, const WCHAR *format,...)
 
int vsprintfW (WCHAR *str, const WCHAR *format, va_list valist)
 
int vsnprintfW (WCHAR *str, size_t len, const WCHAR *format, va_list valist)
 
WINE_UNICODE_INLINE int wine_is_dbcs_leadbyte (const union cptable *table, unsigned char ch)
 
WINE_UNICODE_INLINE WCHAR tolowerW (WCHAR ch)
 
WINE_UNICODE_INLINE WCHAR toupperW (WCHAR ch)
 
WINE_UNICODE_INLINE unsigned short get_char_typeW (WCHAR ch)
 
WINE_UNICODE_INLINE int iscntrlW (WCHAR wc)
 
WINE_UNICODE_INLINE int ispunctW (WCHAR wc)
 
WINE_UNICODE_INLINE int isspaceW (WCHAR wc)
 
WINE_UNICODE_INLINE int isdigitW (WCHAR wc)
 
WINE_UNICODE_INLINE int isxdigitW (WCHAR wc)
 
WINE_UNICODE_INLINE int islowerW (WCHAR wc)
 
WINE_UNICODE_INLINE int isupperW (WCHAR wc)
 
WINE_UNICODE_INLINE int isalnumW (WCHAR wc)
 
WINE_UNICODE_INLINE int isalphaW (WCHAR wc)
 
WINE_UNICODE_INLINE int isgraphW (WCHAR wc)
 
WINE_UNICODE_INLINE int isprintW (WCHAR wc)
 
WINE_UNICODE_INLINE unsigned int strlenW (const WCHAR *str)
 
WINE_UNICODE_INLINE WCHARstrcpyW (WCHAR *dst, const WCHAR *src)
 
WINE_UNICODE_INLINE int strcmpW (const WCHAR *str1, const WCHAR *str2)
 
WINE_UNICODE_INLINE int strncmpW (const WCHAR *str1, const WCHAR *str2, int n)
 
WINE_UNICODE_INLINE WCHARstrcatW (WCHAR *dst, const WCHAR *src)
 
WINE_UNICODE_INLINE WCHARstrchrW (const WCHAR *str, WCHAR ch)
 
WINE_UNICODE_INLINE WCHARstrrchrW (const WCHAR *str, WCHAR ch)
 
WINE_UNICODE_INLINE WCHARstrpbrkW (const WCHAR *str, const WCHAR *accept)
 
WINE_UNICODE_INLINE size_t strspnW (const WCHAR *str, const WCHAR *accept)
 
WINE_UNICODE_INLINE size_t strcspnW (const WCHAR *str, const WCHAR *reject)
 
WINE_UNICODE_INLINE WCHARstrlwrW (WCHAR *str)
 
WINE_UNICODE_INLINE WCHARstruprW (WCHAR *str)
 
WINE_UNICODE_INLINE WCHARmemchrW (const WCHAR *ptr, WCHAR ch, size_t n)
 
WINE_UNICODE_INLINE WCHARmemrchrW (const WCHAR *ptr, WCHAR ch, size_t n)
 
WINE_UNICODE_INLINE long int atolW (const WCHAR *str)
 
WINE_UNICODE_INLINE int atoiW (const WCHAR *str)
 

Macro Definition Documentation

◆ C1_ALPHA

#define C1_ALPHA   256

Definition at line 39 of file unicode.h.

◆ C1_BLANK

#define C1_BLANK   64

Definition at line 37 of file unicode.h.

◆ C1_CNTRL

#define C1_CNTRL   32

Definition at line 36 of file unicode.h.

◆ C1_DIGIT

#define C1_DIGIT   4

Definition at line 33 of file unicode.h.

◆ C1_LOWER

#define C1_LOWER   2

Definition at line 32 of file unicode.h.

◆ C1_PUNCT

#define C1_PUNCT   16

Definition at line 35 of file unicode.h.

◆ C1_SPACE

#define C1_SPACE   8

Definition at line 34 of file unicode.h.

◆ C1_UPPER

#define C1_UPPER   1

Definition at line 31 of file unicode.h.

◆ C1_XDIGIT

#define C1_XDIGIT   128

Definition at line 38 of file unicode.h.

◆ MB_COMPOSITE

#define MB_COMPOSITE   2

Definition at line 40 of file unicode.h.

◆ MB_ERR_INVALID_CHARS

#define MB_ERR_INVALID_CHARS   8

Definition at line 41 of file unicode.h.

◆ MB_USEGLYPHCHARS

#define MB_USEGLYPHCHARS   0x04

Definition at line 42 of file unicode.h.

◆ strncpyW

#define strncpyW (   d,
  s,
  n 
)    error do_not_use_strncpyW_use_lstrcpynW_or_memcpy_instead

Definition at line 227 of file unicode.h.

◆ WC_COMPOSITECHECK

#define WC_COMPOSITECHECK   512

Definition at line 43 of file unicode.h.

◆ WC_DEFAULTCHAR

#define WC_DEFAULTCHAR   64

Definition at line 45 of file unicode.h.

◆ WC_DISCARDNS

#define WC_DISCARDNS   16

Definition at line 44 of file unicode.h.

◆ WC_ERR_INVALID_CHARS

#define WC_ERR_INVALID_CHARS   0x0080

Definition at line 47 of file unicode.h.

◆ WC_NO_BEST_FIT_CHARS

#define WC_NO_BEST_FIT_CHARS   1024

Definition at line 46 of file unicode.h.

◆ WINE_UNICODE_API

#define WINE_UNICODE_API

Definition at line 58 of file unicode.h.

◆ WINE_UNICODE_INLINE

#define WINE_UNICODE_INLINE   static inline

Definition at line 62 of file unicode.h.

Function Documentation

◆ atoiW()

WINE_UNICODE_INLINE int atoiW ( const WCHAR str)

Definition at line 315 of file unicode.h.

316{
317 return (int)atolW( str );
318}
#define atolW(s)
Definition: unicode.h:61
const WCHAR * str

◆ atolW()

Definition at line 310 of file unicode.h.

311{
312 return strtolW( str, (WCHAR **)0, 10 );
313}
#define strtolW(s, e, b)
Definition: unicode.h:39
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ get_char_typeW()

WINE_UNICODE_INLINE unsigned short get_char_typeW ( WCHAR  ch)

Definition at line 149 of file unicode.h.

150{
151 extern WINE_UNICODE_API const unsigned short wine_wctype_table[];
152 return wine_wctype_table[wine_wctype_table[ch >> 8] + (ch & 0xff)];
153}
const unsigned short wine_wctype_table[]
Definition: wctype.c:6
#define WINE_UNICODE_API
Definition: unicode.h:58

Referenced by compare_case_weights(), compare_diacritic_weights(), compare_unicode_weights(), compare_weights(), GetStringTypeW(), isalnumW(), isalphaW(), iscntrlW(), isdigitW(), isgraphW(), islowerW(), isprintW(), ispunctW(), isspaceW(), isupperW(), isxdigitW(), and wine_get_sortkey().

◆ isalnumW()

WINE_UNICODE_INLINE int isalnumW ( WCHAR  wc)

Definition at line 190 of file unicode.h.

191{
193}
#define C1_DIGIT
Definition: unicode.h:33
#define C1_ALPHA
Definition: unicode.h:39
#define C1_LOWER
Definition: unicode.h:32
#define C1_UPPER
Definition: unicode.h:31
WINE_UNICODE_INLINE unsigned short get_char_typeW(WCHAR ch)
Definition: unicode.h:149

◆ isalphaW()

WINE_UNICODE_INLINE int isalphaW ( WCHAR  wc)

Definition at line 195 of file unicode.h.

196{
198}

◆ iscntrlW()

WINE_UNICODE_INLINE int iscntrlW ( WCHAR  wc)

Definition at line 155 of file unicode.h.

156{
157 return get_char_typeW(wc) & C1_CNTRL;
158}
#define C1_CNTRL
Definition: unicode.h:36

◆ isdigitW()

WINE_UNICODE_INLINE int isdigitW ( WCHAR  wc)

Definition at line 170 of file unicode.h.

171{
172 return get_char_typeW(wc) & C1_DIGIT;
173}

◆ isgraphW()

WINE_UNICODE_INLINE int isgraphW ( WCHAR  wc)

Definition at line 200 of file unicode.h.

201{
203}
#define C1_PUNCT
Definition: unicode.h:35

◆ islowerW()

WINE_UNICODE_INLINE int islowerW ( WCHAR  wc)

Definition at line 180 of file unicode.h.

181{
182 return get_char_typeW(wc) & C1_LOWER;
183}

◆ isprintW()

WINE_UNICODE_INLINE int isprintW ( WCHAR  wc)

Definition at line 205 of file unicode.h.

206{
208}
#define C1_BLANK
Definition: unicode.h:37

◆ ispunctW()

WINE_UNICODE_INLINE int ispunctW ( WCHAR  wc)

Definition at line 160 of file unicode.h.

161{
162 return get_char_typeW(wc) & C1_PUNCT;
163}

◆ isspaceW()

WINE_UNICODE_INLINE int isspaceW ( WCHAR  wc)

Definition at line 165 of file unicode.h.

166{
167 return get_char_typeW(wc) & C1_SPACE;
168}
#define C1_SPACE
Definition: unicode.h:34

◆ isupperW()

WINE_UNICODE_INLINE int isupperW ( WCHAR  wc)

Definition at line 185 of file unicode.h.

186{
187 return get_char_typeW(wc) & C1_UPPER;
188}

◆ isxdigitW()

WINE_UNICODE_INLINE int isxdigitW ( WCHAR  wc)

Definition at line 175 of file unicode.h.

176{
177 return get_char_typeW(wc) & C1_XDIGIT;
178}
#define C1_XDIGIT
Definition: unicode.h:38

◆ memchrW()

WINE_UNICODE_INLINE WCHAR * memchrW ( const WCHAR ptr,
WCHAR  ch,
size_t  n 
)

Definition at line 295 of file unicode.h.

296{
297 const WCHAR *end;
298 for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) return (WCHAR *)(ULONG_PTR)ptr;
299 return NULL;
300}
#define NULL
Definition: types.h:112
#define ULONG_PTR
Definition: config.h:101
GLuint GLuint end
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
static PVOID ptr
Definition: dispmode.c:27

Referenced by get_token(), map_W_to_A(), match_common_name(), PROFILE_Load(), and WinHttpCrackUrl().

◆ memicmpW()

int memicmpW ( const WCHAR str1,
const WCHAR str2,
int  n 
)

Definition at line 51 of file string.c.

52{
53 int ret = 0;
54 for ( ; n > 0; n--, str1++, str2++)
55 if ((ret = tolowerW(*str1) - tolowerW(*str2))) break;
56 return ret;
57}
#define tolowerW(n)
Definition: unicode.h:50
int ret

◆ memrchrW()

WINE_UNICODE_INLINE WCHAR * memrchrW ( const WCHAR ptr,
WCHAR  ch,
size_t  n 
)

Definition at line 302 of file unicode.h.

303{
304 const WCHAR *end;
305 WCHAR *ret = NULL;
306 for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) ret = (WCHAR *)(ULONG_PTR)ptr;
307 return ret;
308}
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by PROFILE_Load().

◆ snprintfW()

int snprintfW ( WCHAR str,
size_t  len,
const WCHAR format,
  ... 
)

Definition at line 520 of file string.c.

521{
522 int retval;
525 retval = vsnprintfW(str, len, format, valist);
526 va_end(valist);
527 return retval;
528}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
GLenum GLsizei len
Definition: glext.h:6722
static __ms_va_list valist
Definition: printf.c:66
#define vsnprintfW
Definition: unicode.h:67
Definition: format.c:58

◆ sprintfW()

int sprintfW ( WCHAR str,
const WCHAR format,
  ... 
)

Definition at line 530 of file string.c.

531{
532 int retval;
535 retval = vsnprintfW(str, INT_MAX, format, valist);
536 va_end(valist);
537 return retval;
538}
#define INT_MAX
Definition: intsafe.h:150

◆ strcatW()

WINE_UNICODE_INLINE WCHAR * strcatW ( WCHAR dst,
const WCHAR src 
)

Definition at line 242 of file unicode.h.

243{
244 strcpyW( dst + strlenW(dst), src );
245 return dst;
246}
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define strlenW(s)
Definition: unicode.h:34
#define strcpyW(d, s)
Definition: unicode.h:35

◆ strchrW()

WINE_UNICODE_INLINE WCHAR * strchrW ( const WCHAR str,
WCHAR  ch 
)

Definition at line 248 of file unicode.h.

249{
250 do { if (*str == ch) return (WCHAR *)(ULONG_PTR)str; } while (*str++);
251 return NULL;
252}

◆ strcmpiW()

int strcmpiW ( const WCHAR str1,
const WCHAR str2 
)

Definition at line 32 of file string.c.

33{
34 for (;;)
35 {
36 int ret = tolowerW(*str1) - tolowerW(*str2);
37 if (ret || !*str1) return ret;
38 str1++;
39 str2++;
40 }
41}

◆ strcmpW()

WINE_UNICODE_INLINE int strcmpW ( const WCHAR str1,
const WCHAR str2 
)

Definition at line 229 of file unicode.h.

230{
231 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
232 return *str1 - *str2;
233}

◆ strcpyW()

WINE_UNICODE_INLINE WCHAR * strcpyW ( WCHAR dst,
const WCHAR src 
)

Definition at line 219 of file unicode.h.

220{
221 WCHAR *p = dst;
222 while ((*p++ = *src++));
223 return dst;
224}
GLfloat GLfloat p
Definition: glext.h:8902

◆ strcspnW()

WINE_UNICODE_INLINE size_t strcspnW ( const WCHAR str,
const WCHAR reject 
)

Definition at line 274 of file unicode.h.

275{
276 const WCHAR *ptr;
277 for (ptr = str; *ptr; ptr++) if (strchrW( reject, *ptr )) break;
278 return ptr - str;
279}
#define strchrW(s, c)
Definition: unicode.h:40

◆ strlenW()

Definition at line 212 of file unicode.h.

213{
214 const WCHAR *s = str;
215 while (*s) s++;
216 return (unsigned int)(s - str);
217}
GLdouble s
Definition: gl.h:2039

◆ strlwrW()

WINE_UNICODE_INLINE WCHAR * strlwrW ( WCHAR str)

Definition at line 281 of file unicode.h.

282{
283 WCHAR *ret = str;
284 while ((*str = tolowerW(*str))) str++;
285 return ret;
286}

◆ strncmpiW()

int strncmpiW ( const WCHAR str1,
const WCHAR str2,
int  n 
)

Definition at line 43 of file string.c.

44{
45 int ret = 0;
46 for ( ; n > 0; n--, str1++, str2++)
47 if ((ret = tolowerW(*str1) - tolowerW(*str2)) || !*str1) break;
48 return ret;
49}

◆ strncmpW()

WINE_UNICODE_INLINE int strncmpW ( const WCHAR str1,
const WCHAR str2,
int  n 
)

Definition at line 235 of file unicode.h.

236{
237 if (n <= 0) return 0;
238 while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
239 return *str1 - *str2;
240}

◆ strpbrkW()

WINE_UNICODE_INLINE WCHAR * strpbrkW ( const WCHAR str,
const WCHAR accept 
)

Definition at line 261 of file unicode.h.

262{
263 for ( ; *str; str++) if (strchrW( accept, *str )) return (WCHAR *)(ULONG_PTR)str;
264 return NULL;
265}
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23

◆ strrchrW()

WINE_UNICODE_INLINE WCHAR * strrchrW ( const WCHAR str,
WCHAR  ch 
)

Definition at line 254 of file unicode.h.

255{
256 WCHAR *ret = NULL;
257 do { if (*str == ch) ret = (WCHAR *)(ULONG_PTR)str; } while (*str++);
258 return ret;
259}

◆ strspnW()

WINE_UNICODE_INLINE size_t strspnW ( const WCHAR str,
const WCHAR accept 
)

Definition at line 267 of file unicode.h.

268{
269 const WCHAR *ptr;
270 for (ptr = str; *ptr; ptr++) if (!strchrW( accept, *ptr )) break;
271 return ptr - str;
272}

◆ strstrW()

WCHAR * strstrW ( const WCHAR str,
const WCHAR sub 
)

Definition at line 59 of file string.c.

60{
61 while (*str)
62 {
63 const WCHAR *p1 = str, *p2 = sub;
64 while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
65 if (!*p2) return (WCHAR *)str;
66 str++;
67 }
68 return NULL;
69}

◆ strtolW()

long int strtolW ( const WCHAR nptr,
WCHAR **  endptr,
int  base 
)

Definition at line 74 of file string.c.

75{
76 int negative;
77 register unsigned long int cutoff;
78 register unsigned int cutlim;
79 register unsigned long int i;
80 register const WCHAR *s;
81 register WCHAR c;
82 const WCHAR *save, *end;
83 int overflow;
84
85 if (base < 0 || base == 1 || base > 36) return 0;
86
87 save = s = nptr;
88
89 /* Skip white space. */
90 while (isspaceW (*s))
91 ++s;
92 if (!*s) goto noconv;
93
94 /* Check for a sign. */
95 negative = 0;
96 if (*s == '-')
97 {
98 negative = 1;
99 ++s;
100 }
101 else if (*s == '+')
102 ++s;
103
104 /* Recognize number prefix and if BASE is zero, figure it out ourselves. */
105 if (*s == '0')
106 {
107 if ((base == 0 || base == 16) && toupperW(s[1]) == 'X')
108 {
109 s += 2;
110 base = 16;
111 }
112 else if (base == 0)
113 base = 8;
114 }
115 else if (base == 0)
116 base = 10;
117
118 /* Save the pointer so we can check later if anything happened. */
119 save = s;
120 end = NULL;
121
122 cutoff = ULONG_MAX / (unsigned long int) base;
123 cutlim = ULONG_MAX % (unsigned long int) base;
124
125 overflow = 0;
126 i = 0;
127 c = *s;
128 for (;c != '\0'; c = *++s)
129 {
130 if (s == end)
131 break;
132 if (c >= '0' && c <= '9')
133 c -= '0';
134 else if (isalphaW (c))
135 c = toupperW (c) - 'A' + 10;
136 else
137 break;
138 if ((int) c >= base)
139 break;
140 /* Check for overflow. */
141 if (i > cutoff || (i == cutoff && c > cutlim))
142 overflow = 1;
143 else
144 {
145 i *= (unsigned long int) base;
146 i += c;
147 }
148 }
149
150 /* Check if anything actually happened. */
151 if (s == save)
152 goto noconv;
153
154 /* Store in ENDPTR the address of one character
155 past the last character we converted. */
156 if (endptr != NULL)
157 *endptr = (WCHAR *)s;
158
159 /* Check for a value that is within the range of
160 `unsigned LONG int', but outside the range of `LONG int'. */
161 if (overflow == 0
162 && i > (negative
163 ? -((unsigned long int) (LONG_MIN + 1)) + 1
164 : (unsigned long int) LONG_MAX))
165 overflow = 1;
166
167 if (overflow)
168 {
169 errno = ERANGE;
170 return negative ? LONG_MIN : LONG_MAX;
171 }
172
173 /* Return the result of the appropriate sign. */
174 return negative ? -i : i;
175
176noconv:
177 /* We must handle a special case here: the base is 0 or 16 and the
178 first two characters are '0' and 'x', but the rest are not
179 hexadecimal digits. This is no error case. We return 0 and
180 ENDPTR points to the `x`. */
181 if (endptr != NULL)
182 {
183 if (save - nptr >= 2 && toupperW (save[-1]) == 'X'
184 && save[-2] == '0')
185 *endptr = (WCHAR *)&save[-1];
186 else
187 /* There was no number to convert. */
188 *endptr = (WCHAR *)nptr;
189 }
190
191 return 0L;
192}
#define ERANGE
Definition: acclib.h:92
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
const GLubyte * c
Definition: glext.h:8905
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ULONG_MAX
Definition: intsafe.h:155
#define LONG_MAX
Definition: intsafe.h:154
#define LONG_MIN
Definition: intsafe.h:125
#define c
Definition: ke_i.h:80
#define L(x)
Definition: ntvdm.h:50
#define toupperW(n)
Definition: unicode.h:51
#define isspaceW(n)
Definition: unicode.h:58
#define isalphaW(n)
Definition: unicode.h:54
#define errno
Definition: errno.h:18

◆ strtoulW()

unsigned long int strtoulW ( const WCHAR nptr,
WCHAR **  endptr,
int  base 
)

Definition at line 195 of file string.c.

196{
197 int negative;
198 register unsigned long int cutoff;
199 register unsigned int cutlim;
200 register unsigned long int i;
201 register const WCHAR *s;
202 register WCHAR c;
203 const WCHAR *save, *end;
204 int overflow;
205
206 if (base < 0 || base == 1 || base > 36) return 0;
207
208 save = s = nptr;
209
210 /* Skip white space. */
211 while (isspaceW (*s))
212 ++s;
213 if (!*s) goto noconv;
214
215 /* Check for a sign. */
216 negative = 0;
217 if (*s == '-')
218 {
219 negative = 1;
220 ++s;
221 }
222 else if (*s == '+')
223 ++s;
224
225 /* Recognize number prefix and if BASE is zero, figure it out ourselves. */
226 if (*s == '0')
227 {
228 if ((base == 0 || base == 16) && toupperW(s[1]) == 'X')
229 {
230 s += 2;
231 base = 16;
232 }
233 else if (base == 0)
234 base = 8;
235 }
236 else if (base == 0)
237 base = 10;
238
239 /* Save the pointer so we can check later if anything happened. */
240 save = s;
241 end = NULL;
242
243 cutoff = ULONG_MAX / (unsigned long int) base;
244 cutlim = ULONG_MAX % (unsigned long int) base;
245
246 overflow = 0;
247 i = 0;
248 c = *s;
249 for (;c != '\0'; c = *++s)
250 {
251 if (s == end)
252 break;
253 if (c >= '0' && c <= '9')
254 c -= '0';
255 else if (isalphaW (c))
256 c = toupperW (c) - 'A' + 10;
257 else
258 break;
259 if ((int) c >= base)
260 break;
261 /* Check for overflow. */
262 if (i > cutoff || (i == cutoff && c > cutlim))
263 overflow = 1;
264 else
265 {
266 i *= (unsigned long int) base;
267 i += c;
268 }
269 }
270
271 /* Check if anything actually happened. */
272 if (s == save)
273 goto noconv;
274
275 /* Store in ENDPTR the address of one character
276 past the last character we converted. */
277 if (endptr != NULL)
278 *endptr = (WCHAR *)s;
279
280 if (overflow)
281 {
282 errno = ERANGE;
283 return ULONG_MAX;
284 }
285
286 /* Return the result of the appropriate sign. */
287 return negative ? -i : i;
288
289noconv:
290 /* We must handle a special case here: the base is 0 or 16 and the
291 first two characters are '0' and 'x', but the rest are not
292 hexadecimal digits. This is no error case. We return 0 and
293 ENDPTR points to the `x`. */
294 if (endptr != NULL)
295 {
296 if (save - nptr >= 2 && toupperW (save[-1]) == 'X'
297 && save[-2] == '0')
298 *endptr = (WCHAR *)&save[-1];
299 else
300 /* There was no number to convert. */
301 *endptr = (WCHAR *)nptr;
302 }
303
304 return 0L;
305}

◆ struprW()

WINE_UNICODE_INLINE WCHAR * struprW ( WCHAR str)

Definition at line 288 of file unicode.h.

289{
290 WCHAR *ret = str;
291 while ((*str = toupperW(*str))) str++;
292 return ret;
293}

◆ tolowerW()

WINE_UNICODE_INLINE WCHAR tolowerW ( WCHAR  ch)

Definition at line 135 of file unicode.h.

136{
138 return ch + wine_casemap_lower[wine_casemap_lower[ch >> 8] + (ch & 0xff)];
139}
const WCHAR wine_casemap_lower[4013]
Definition: casemap.c:7

◆ toupperW()

WINE_UNICODE_INLINE WCHAR toupperW ( WCHAR  ch)

Definition at line 141 of file unicode.h.

142{
144 return ch + wine_casemap_upper[wine_casemap_upper[ch >> 8] + (ch & 0xff)];
145}
const WCHAR wine_casemap_upper[4570]
Definition: casemap.c:533

◆ vsnprintfW()

int vsnprintfW ( WCHAR str,
size_t  len,
const WCHAR format,
va_list  valist 
)

Definition at line 363 of file string.c.

364{
365 unsigned int written = 0;
366 const WCHAR *iter = format;
367 char bufa[512], fmtbufa[64], *fmta;
368
369 while (*iter)
370 {
371 while (*iter && *iter != '%')
372 {
373 if (written++ < len)
374 *str++ = *iter;
375 iter++;
376 }
377 if (*iter == '%')
378 {
379 if (iter[1] == '%')
380 {
381 if (written++ < len)
382 *str++ = '%'; /* "%%"->'%' */
383 iter += 2;
384 continue;
385 }
386
387 fmta = fmtbufa;
388 *fmta++ = *iter++;
389 while (*iter == '0' ||
390 *iter == '+' ||
391 *iter == '-' ||
392 *iter == ' ' ||
393 *iter == '*' ||
394 *iter == '#')
395 {
396 if (*iter == '*')
397 {
398 char *buffiter = bufa;
399 int fieldlen = va_arg(valist, int);
400 sprintf(buffiter, "%d", fieldlen);
401 while (*buffiter)
402 *fmta++ = *buffiter++;
403 }
404 else
405 *fmta++ = *iter;
406 iter++;
407 }
408
409 while (isdigit(*iter))
410 *fmta++ = *iter++;
411
412 if (*iter == '.')
413 {
414 *fmta++ = *iter++;
415 if (*iter == '*')
416 {
417 char *buffiter = bufa;
418 int fieldlen = va_arg(valist, int);
419 sprintf(buffiter, "%d", fieldlen);
420 while (*buffiter)
421 *fmta++ = *buffiter++;
422 iter++;
423 }
424 else
425 while (isdigit(*iter))
426 *fmta++ = *iter++;
427 }
428 if (*iter == 'h' || *iter == 'l')
429 *fmta++ = *iter++;
430
431 switch (*iter)
432 {
433 case 's':
434 {
435 static const WCHAR none[] = { '(','n','u','l','l',')',0 };
436 const WCHAR *wstr = va_arg(valist, const WCHAR *);
437 size_t remaining = written < len ? len - written : 0;
438 size_t count;
439
440 *fmta++ = 's';
441 *fmta = 0;
442 count = format_string( str, remaining, fmtbufa, wstr ? wstr : none, -1 );
443 str += min( count, remaining );
444 written += count;
445 iter++;
446 break;
447 }
448
449 case 'c':
450 {
451 WCHAR wstr;
452 size_t remaining = written < len ? len - written : 0;
453 size_t count;
454
455 wstr = va_arg(valist, int);
456 *fmta++ = 's';
457 *fmta = 0;
458 count = format_string( str, remaining, fmtbufa, &wstr, 1 );
459 str += min( count, remaining );
460 written += count;
461 iter++;
462 break;
463 }
464
465 default:
466 {
467 /* For non wc types, use system sprintf and append to wide char output */
468 /* FIXME: for unrecognised types, should ignore % when printing */
469 char *bufaiter = bufa;
470 if (*iter == 'p')
471#ifdef __REACTOS__
472 sprintf(bufaiter, "%p", va_arg(valist, void*));
473#else
474 sprintf(bufaiter, "%0*lX", 2 * (int)sizeof(void*),
475 (unsigned long)va_arg(valist, void *));
476#endif
477 else
478 {
479 *fmta++ = *iter;
480 *fmta = '\0';
481 if (*iter == 'a' || *iter == 'A' ||
482 *iter == 'e' || *iter == 'E' ||
483 *iter == 'f' || *iter == 'F' ||
484 *iter == 'g' || *iter == 'G')
485 sprintf(bufaiter, fmtbufa, va_arg(valist, double));
486 else
487 {
488 /* FIXME: On 32 bit systems this doesn't handle int 64's. */
489 sprintf(bufaiter, fmtbufa, va_arg(valist, void *));
490 }
491 }
492 while (*bufaiter)
493 {
494 if (written++ < len)
495 *str++ = *bufaiter;
496 bufaiter++;
497 }
498 iter++;
499 break;
500 }
501 }
502 }
503 }
504 if (len)
505 {
506 if (written >= len)
507 str--;
508 *str++ = 0;
509 }
510
511 /* FIXME: POSIX [v]snprintf() returns the equivalent of written, not -1, on short buffer. */
512 return written < len ? (int)written : -1;
513}
#define isdigit(c)
Definition: acclib.h:68
#define va_arg(ap, T)
Definition: acmsvcex.h:89
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define min(a, b)
Definition: monoChain.cc:55
static size_t format_string(WCHAR *buffer, size_t len, const char *format, const WCHAR *str, int str_len)
Definition: string.c:309

◆ vsprintfW()

int vsprintfW ( WCHAR str,
const WCHAR format,
va_list  valist 
)

Definition at line 515 of file string.c.

516{
517 return vsnprintfW( str, INT_MAX, format, valist );
518}

◆ wine_compare_string()

int wine_compare_string ( int  flags,
const WCHAR str1,
int  len1,
const WCHAR str2,
int  len2 
)

Definition at line 358 of file sortkey.c.

360{
361 int ret;
362
363 ret = compare_unicode_weights(flags, str1, len1, str2, len2);
364 if (!ret)
365 {
366 if (!(flags & NORM_IGNORENONSPACE))
367 ret = compare_diacritic_weights(flags, str1, len1, str2, len2);
368 if (!ret && !(flags & NORM_IGNORECASE))
369 ret = compare_case_weights(flags, str1, len1, str2, len2);
370 }
371 return ret;
372}
static int compare_case_weights(int flags, const WCHAR *str1, int len1, const WCHAR *str2, int len2)
Definition: sortkey.c:299
static int compare_diacritic_weights(int flags, const WCHAR *str1, int len1, const WCHAR *str2, int len2)
Definition: sortkey.c:240
static int compare_unicode_weights(int flags, const WCHAR *str1, int len1, const WCHAR *str2, int len2)
Definition: sortkey.c:159
GLbitfield flags
Definition: glext.h:7161
#define NORM_IGNORECASE
Definition: winnls.h:178
#define NORM_IGNORENONSPACE
Definition: winnls.h:180

◆ wine_cp_enum_table()

const union cptable * wine_cp_enum_table ( unsigned int  index)

Definition at line 203 of file cptable.c.

204{
205 if (index >= ARRAY_SIZE( cptables )) return NULL;
206 return cptables[index];
207}
#define index(s, c)
Definition: various.h:29
#define ARRAY_SIZE(x)
Definition: cptable.c:26
static const union cptable *const cptables[73]
Definition: cptable.c:105
GLuint index
Definition: glext.h:6031

Referenced by EnumSystemCodePagesA(), and EnumSystemCodePagesW().

◆ wine_cp_get_table()

const union cptable * wine_cp_get_table ( unsigned int  codepage)

Definition at line 192 of file cptable.c.

193{
194 const union cptable **res;
195
197 sizeof(cptables[0]), cmp_codepage ))) return NULL;
198 return *res;
199}
static int cmp_codepage(const void *codepage, const void *entry)
Definition: cptable.c:185
GLuint res
Definition: glext.h:9613
#define bsearch
int codepage
Definition: win_iconv.c:156

Referenced by get_codepage_table(), IsValidCodePage(), LOCALE_Init(), and SetCPGlobal().

◆ wine_cp_mbstowcs()

int wine_cp_mbstowcs ( const union cptable table,
int  flags,
const char src,
int  srclen,
WCHAR dst,
int  dstlen 
)

Definition at line 265 of file mbtowc.c.

268{
269 const unsigned char *src = (const unsigned char*) s;
270
271 if (table->info.char_size == 1)
272 {
274 {
275 if (check_invalid_chars_sbcs( &table->sbcs, flags, src, srclen )) return -2;
276 }
277 if (!(flags & MB_COMPOSITE))
278 {
279 if (!dstlen) return srclen;
280 return mbstowcs_sbcs( &table->sbcs, flags, src, srclen, dst, dstlen );
281 }
282 return mbstowcs_sbcs_decompose( &table->sbcs, flags, src, srclen, dst, dstlen );
283 }
284 else /* mbcs */
285 {
287 {
288 if (check_invalid_chars_dbcs( &table->dbcs, src, srclen )) return -2;
289 }
290 if (!(flags & MB_COMPOSITE))
291 return mbstowcs_dbcs( &table->dbcs, src, srclen, dst, dstlen );
292 else
293 return mbstowcs_dbcs_decompose( &table->dbcs, src, srclen, dst, dstlen );
294 }
295}
#define MB_COMPOSITE
Definition: unicode.h:40
#define MB_ERR_INVALID_CHARS
Definition: unicode.h:41
static DWORD LPDWORD LPCSTR DWORD srclen
Definition: directory.c:52
static DWORD dstlen
Definition: directory.c:51
static int mbstowcs_dbcs(const struct dbcs_table *table, const unsigned char *src, unsigned int srclen, WCHAR *dst, unsigned int dstlen)
Definition: mbtowc.c:191
static int mbstowcs_sbcs_decompose(const struct sbcs_table *table, int flags, const unsigned char *src, unsigned int srclen, WCHAR *dst, unsigned int dstlen)
Definition: mbtowc.c:117
static int mbstowcs_sbcs(const struct sbcs_table *table, int flags, const unsigned char *src, unsigned int srclen, WCHAR *dst, unsigned int dstlen)
Definition: mbtowc.c:54
static int check_invalid_chars_sbcs(const struct sbcs_table *table, int flags, const unsigned char *src, unsigned int srclen)
Definition: mbtowc.c:35
static int mbstowcs_dbcs_decompose(const struct dbcs_table *table, const unsigned char *src, unsigned int srclen, WCHAR *dst, unsigned int dstlen)
Definition: mbtowc.c:218
static int check_invalid_chars_dbcs(const struct dbcs_table *table, const unsigned char *src, unsigned int srclen)
Definition: mbtowc.c:162

Referenced by MultiByteToWideChar().

◆ wine_cp_wcstombs()

int wine_cp_wcstombs ( const union cptable table,
int  flags,
const WCHAR src,
int  srclen,
char dst,
int  dstlen,
const char defchar,
int used 
)

Definition at line 411 of file wctomb.c.

414{
415 if (table->info.char_size == 1)
416 {
417 if (flags || defchar || used)
418 {
419 if (!dstlen) return get_length_sbcs( &table->sbcs, flags, src, srclen, used );
420 return wcstombs_sbcs_slow( &table->sbcs, flags, src, srclen,
421 dst, dstlen, defchar, used );
422 }
423 if (!dstlen) return srclen;
424 return wcstombs_sbcs( &table->sbcs, src, srclen, dst, dstlen );
425 }
426 else /* mbcs */
427 {
428 if (!dstlen) return get_length_dbcs( &table->dbcs, flags, src, srclen, defchar, used );
429 if (flags || defchar || used)
430 return wcstombs_dbcs_slow( &table->dbcs, flags, src, srclen,
431 dst, dstlen, defchar, used );
432 return wcstombs_dbcs( &table->dbcs, src, srclen, dst, dstlen );
433 }
434}
static int used
Definition: adh-main.c:39
static int wcstombs_dbcs(const struct dbcs_table *table, const WCHAR *src, unsigned int srclen, char *dst, unsigned int dstlen)
Definition: wctomb.c:317
static int get_length_sbcs(const struct sbcs_table *table, int flags, const WCHAR *src, unsigned int srclen, int *used)
Definition: wctomb.c:40
static int get_length_dbcs(const struct dbcs_table *table, int flags, const WCHAR *src, unsigned int srclen, const char *defchar, int *used)
Definition: wctomb.c:249
static int wcstombs_sbcs(const struct sbcs_table *table, const WCHAR *src, unsigned int srclen, char *dst, unsigned int dstlen)
Definition: wctomb.c:92
static int wcstombs_sbcs_slow(const struct sbcs_table *table, int flags, const WCHAR *src, unsigned int srclen, char *dst, unsigned int dstlen, const char *defchar, int *used)
Definition: wctomb.c:156
static int wcstombs_dbcs_slow(const struct dbcs_table *table, int flags, const WCHAR *src, unsigned int srclen, char *dst, unsigned int dstlen, const char *defchar, int *used)
Definition: wctomb.c:341

Referenced by WideCharToMultiByte().

◆ wine_cpsymbol_mbstowcs()

int wine_cpsymbol_mbstowcs ( const char src,
int  srclen,
WCHAR dst,
int  dstlen 
)

Referenced by MultiByteToWideChar().

◆ wine_cpsymbol_wcstombs()

int wine_cpsymbol_wcstombs ( const WCHAR src,
int  srclen,
char dst,
int  dstlen 
)

Referenced by WideCharToMultiByte().

◆ wine_fold_string()

int wine_fold_string ( int  flags,
const WCHAR src,
int  srclen,
WCHAR dst,
int  dstlen 
)

Definition at line 118 of file fold.c.

119{
120 WCHAR *dstbase = dst;
121 const WCHAR *expand;
122 int i;
123
124 if (srclen == -1)
125 srclen = strlenW(src) + 1; /* Include terminating NUL in count */
126
127 if (!dstlen)
128 {
129 /* Calculate the required size for dst */
130 dstlen = srclen;
131
132 if (flags & MAP_EXPAND_LIGATURES)
133 {
134 while (srclen--)
135 {
137 src++;
138 }
139 }
140 else if (flags & MAP_COMPOSITE)
141 {
142 /* FIXME */
143 }
144 else if (flags & MAP_PRECOMPOSED)
145 {
146 /* FIXME */
147 }
148 return dstlen;
149 }
150
151 if (srclen > dstlen)
152 return 0;
153
154 dstlen -= srclen;
155
156 /* Actually perform the mapping(s) specified */
157 for (i = 0; i < srclen; i++)
158 {
159 WCHAR ch = *src;
160
161 if (flags & MAP_EXPAND_LIGATURES)
162 {
163 expand = get_ligature(ch);
164 if (expand[0])
165 {
166 if (!dstlen--)
167 return 0;
168 dst[0] = expand[0];
169 if (expand[2])
170 {
171 if (!dstlen--)
172 return 0;
173 *++dst = expand[1];
174 ch = expand[2];
175 }
176 else
177 ch = expand[1];
178 dst++;
179 }
180 }
181 else if (flags & MAP_COMPOSITE)
182 {
183 /* FIXME */
184 }
185 else if (flags & MAP_PRECOMPOSED)
186 {
187 /* FIXME */
188 }
189 if (flags & MAP_FOLDDIGITS)
190 ch = to_unicode_digit(ch);
191 if (flags & MAP_FOLDCZONE)
192 ch = to_unicode_native(ch);
193
194 *dst++ = ch;
195 src++;
196 }
197 return dst - dstbase;
198}
static BOOL expand(LPINT ac, LPTSTR **arg, LPCTSTR pattern)
Definition: misc.c:228
static WCHAR to_unicode_digit(WCHAR ch)
Definition: fold.c:23
static WCHAR to_unicode_native(WCHAR ch)
Definition: fold.c:29
static const WCHAR * get_ligature(WCHAR wc)
Definition: fold.c:100
static int get_ligature_len(WCHAR wc)
Definition: fold.c:84
#define MAP_FOLDDIGITS
Definition: winnls.h:216
#define MAP_PRECOMPOSED
Definition: winnls.h:217
#define MAP_COMPOSITE
Definition: winnls.h:218
#define MAP_FOLDCZONE
Definition: winnls.h:215

◆ wine_get_sortkey()

int wine_get_sortkey ( int  flags,
const WCHAR src,
int  srclen,
char dst,
int  dstlen 
)

Definition at line 33 of file sortkey.c.

34{
35 WCHAR dummy[4]; /* no decomposition is larger than 4 chars */
36 int key_len[4];
37 char *key_ptr[4];
38 const WCHAR *src_save = src;
39 int srclen_save = srclen;
40
41 key_len[0] = key_len[1] = key_len[2] = key_len[3] = 0;
42 for (; srclen; srclen--, src++)
43 {
44 unsigned int i, decomposed_len = 1;/*wine_decompose(*src, dummy, 4);*/
45 dummy[0] = *src;
46 if (decomposed_len)
47 {
48 for (i = 0; i < decomposed_len; i++)
49 {
50 WCHAR wch = dummy[i];
51 unsigned int ce;
52
53 /* tests show that win2k just ignores NORM_IGNORENONSPACE,
54 * and skips white space and punctuation characters for
55 * NORM_IGNORESYMBOLS.
56 */
58 continue;
59
60 if (flags & NORM_IGNORECASE) wch = tolowerW(wch);
61
62 ce = collation_table[collation_table[wch >> 8] + (wch & 0xff)];
63 if (ce != (unsigned int)-1)
64 {
65 if (ce >> 16) key_len[0] += 2;
66 if ((ce >> 8) & 0xff) key_len[1]++;
67 if ((ce >> 4) & 0x0f) key_len[2]++;
68 if (ce & 1)
69 {
70 if (wch >> 8) key_len[3]++;
71 key_len[3]++;
72 }
73 }
74 else
75 {
76 key_len[0] += 2;
77 if (wch >> 8) key_len[0]++;
78 if (wch & 0xff) key_len[0]++;
79 }
80 }
81 }
82 }
83
84 if (!dstlen) /* compute length */
85 /* 4 * '\1' + 1 * '\0' + key length */
86 return key_len[0] + key_len[1] + key_len[2] + key_len[3] + 4 + 1;
87
88 if (dstlen < key_len[0] + key_len[1] + key_len[2] + key_len[3] + 4 + 1)
89 return 0; /* overflow */
90
91 src = src_save;
92 srclen = srclen_save;
93
94 key_ptr[0] = dst;
95 key_ptr[1] = key_ptr[0] + key_len[0] + 1;
96 key_ptr[2] = key_ptr[1] + key_len[1] + 1;
97 key_ptr[3] = key_ptr[2] + key_len[2] + 1;
98
99 for (; srclen; srclen--, src++)
100 {
101 unsigned int i, decomposed_len = 1;/*wine_decompose(*src, dummy, 4);*/
102 dummy[0] = *src;
103 if (decomposed_len)
104 {
105 for (i = 0; i < decomposed_len; i++)
106 {
107 WCHAR wch = dummy[i];
108 unsigned int ce;
109
110 /* tests show that win2k just ignores NORM_IGNORENONSPACE,
111 * and skips white space and punctuation characters for
112 * NORM_IGNORESYMBOLS.
113 */
115 continue;
116
117 if (flags & NORM_IGNORECASE) wch = tolowerW(wch);
118
119 ce = collation_table[collation_table[wch >> 8] + (wch & 0xff)];
120 if (ce != (unsigned int)-1)
121 {
122 WCHAR key;
123 if ((key = ce >> 16))
124 {
125 *key_ptr[0]++ = key >> 8;
126 *key_ptr[0]++ = key & 0xff;
127 }
128 /* make key 1 start from 2 */
129 if ((key = (ce >> 8) & 0xff)) *key_ptr[1]++ = key + 1;
130 /* make key 2 start from 2 */
131 if ((key = (ce >> 4) & 0x0f)) *key_ptr[2]++ = key + 1;
132 /* key 3 is always a character code */
133 if (ce & 1)
134 {
135 if (wch >> 8) *key_ptr[3]++ = wch >> 8;
136 if (wch & 0xff) *key_ptr[3]++ = wch & 0xff;
137 }
138 }
139 else
140 {
141 *key_ptr[0]++ = 0xff;
142 *key_ptr[0]++ = 0xfe;
143 if (wch >> 8) *key_ptr[0]++ = wch >> 8;
144 if (wch & 0xff) *key_ptr[0]++ = wch & 0xff;
145 }
146 }
147 }
148 }
149
150 *key_ptr[0] = '\1';
151 *key_ptr[1] = '\1';
152 *key_ptr[2] = '\1';
153 *key_ptr[3]++ = '\1';
154 *key_ptr[3] = 0;
155
156 return key_ptr[3] - dst;
157}
const unsigned int collation_table[]
Definition: collation.c:5
Definition: copy.c:22
#define NORM_IGNORESYMBOLS
Definition: winnls.h:181

◆ wine_is_dbcs_leadbyte()

WINE_UNICODE_INLINE int wine_is_dbcs_leadbyte ( const union cptable table,
unsigned char  ch 
)

Definition at line 130 of file unicode.h.

131{
132 return (table->info.char_size == 2) && (table->dbcs.cp2uni_leadbytes[ch]);
133}

Referenced by IsDBCSLeadByte(), and IsDBCSLeadByteEx().

◆ wine_utf8_mbstowcs()

int wine_utf8_mbstowcs ( int  flags,
const char src,
int  srclen,
WCHAR dst,
int  dstlen 
)

Definition at line 304 of file utf8.c.

305{
306 unsigned int res;
307 const char *srcend = src + srclen;
308 WCHAR *dstend = dst + dstlen;
309
311
312 if (!dstlen) return get_length_mbs_utf8( flags, src, srclen );
313
314 while ((dst < dstend) && (src < srcend))
315 {
316 unsigned char ch = *src++;
317 if (ch < 0x80) /* special fast case for 7-bit ASCII */
318 {
319 *dst++ = ch;
320 continue;
321 }
322 if ((res = decode_utf8_char( ch, &src, srcend )) <= 0xffff)
323 {
324 *dst++ = res;
325 }
326 else if (res <= 0x10ffff) /* we need surrogates */
327 {
328 if (dst == dstend - 1) return -1; /* overflow */
329 res -= 0x10000;
330 *dst++ = 0xd800 | (res >> 10);
331 *dst++ = 0xdc00 | (res & 0x3ff);
332 }
333 else if (flags & MB_ERR_INVALID_CHARS) return -2; /* bad char */
334 /* otherwise ignore it */
335 }
336 if (src < srcend) return -1; /* overflow */
337 return dstlen - (dstend - dst);
338}
static unsigned int decode_utf8_char(unsigned char ch, const char **str, const char *strend)
Definition: utf8.c:161
static int get_length_mbs_utf8(int flags, const char *src, int srclen)
Definition: utf8.c:277
static int utf8_mbstowcs_compose(int flags, const char *src, int srclen, WCHAR *dst, int dstlen)
Definition: utf8.c:229

Referenced by MultiByteToWideChar().

◆ wine_utf8_wcstombs()

int wine_utf8_wcstombs ( int  flags,
const WCHAR src,
int  srclen,
char dst,
int  dstlen 
)

Definition at line 98 of file utf8.c.

99{
100 int len;
101
102 if (!dstlen) return get_length_wcs_utf8( flags, src, srclen );
103
104 for (len = dstlen; srclen; srclen--, src++)
105 {
106 WCHAR ch = *src;
107 unsigned int val;
108
109 if (ch < 0x80) /* 0x00-0x7f: 1 byte */
110 {
111 if (!len--) return -1; /* overflow */
112 *dst++ = ch;
113 continue;
114 }
115
116 if (ch < 0x800) /* 0x80-0x7ff: 2 bytes */
117 {
118 if ((len -= 2) < 0) return -1; /* overflow */
119 dst[1] = 0x80 | (ch & 0x3f);
120 ch >>= 6;
121 dst[0] = 0xc0 | ch;
122 dst += 2;
123 continue;
124 }
125
126 if (!(val = get_surrogate_value( src, srclen )))
127 {
128 if (flags & WC_ERR_INVALID_CHARS) return -2;
129 continue;
130 }
131
132 if (val < 0x10000) /* 0x800-0xffff: 3 bytes */
133 {
134 if ((len -= 3) < 0) return -1; /* overflow */
135 dst[2] = 0x80 | (val & 0x3f);
136 val >>= 6;
137 dst[1] = 0x80 | (val & 0x3f);
138 val >>= 6;
139 dst[0] = 0xe0 | val;
140 dst += 3;
141 }
142 else /* 0x10000-0x10ffff: 4 bytes */
143 {
144 if ((len -= 4) < 0) return -1; /* overflow */
145 dst[3] = 0x80 | (val & 0x3f);
146 val >>= 6;
147 dst[2] = 0x80 | (val & 0x3f);
148 val >>= 6;
149 dst[1] = 0x80 | (val & 0x3f);
150 val >>= 6;
151 dst[0] = 0xf0 | val;
152 dst += 4;
153 src++;
154 srclen--;
155 }
156 }
157 return dstlen - len;
158}
GLuint GLfloat * val
Definition: glext.h:7180
#define WC_ERR_INVALID_CHARS
Definition: unicode.h:47
static int get_length_wcs_utf8(int flags, const WCHAR *src, unsigned int srclen)
Definition: utf8.c:62
static unsigned int get_surrogate_value(const WCHAR *src, unsigned int srclen)
Definition: utf8.c:48

Referenced by WideCharToMultiByte().