1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
/*
**********************************************************************
* Copyright (C) 1999-2007, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* file name: ustr_imp.h
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
*
* created on: 2001jan30
* created by: Markus W. Scherer
*/
#ifndef __USTR_IMP_H__
#define __USTR_IMP_H__
#include "unicode/utypes.h"
#include "unicode/uiter.h"
#include "ucase.h"
/** Simple declaration for u_strToTitle() to avoid including unicode/ubrk.h. */
#ifndef UBRK_TYPEDEF_UBREAK_ITERATOR
# define UBRK_TYPEDEF_UBREAK_ITERATOR
typedef void UBreakIterator;
#endif
/**
* Compare two strings in code point order or code unit order.
* Works in strcmp style (both lengths -1),
* strncmp style (lengths equal and >=0, flag TRUE),
* and memcmp/UnicodeString style (at least one length >=0).
* @internal
*/
U_CAPI int32_t U_EXPORT2
uprv_strCompare(const UChar *s1, int32_t length1,
const UChar *s2, int32_t length2,
UBool strncmpStyle, UBool codePointOrder);
/**
* Internal API, used by u_strcasecmp() etc.
* Compare strings case-insensitively,
* in code point order or code unit order.
* @internal
*/
U_CFUNC int32_t
u_strcmpFold(const UChar *s1, int32_t length1,
const UChar *s2, int32_t length2,
uint32_t options,
UErrorCode *pErrorCode);
/**
* Are the Unicode properties loaded?
* This must be used before internal functions are called that do
* not perform this check.
* Generate a debug assertion failure if data is not loaded, to flag the fact
* that u_init() wasn't called first, before trying to access character properties.
* @internal
*/
U_CFUNC UBool
uprv_haveProperties(UErrorCode *pErrorCode);
/**
* Load the Unicode property data.
* Intended primarily for use from u_init().
* Has no effect if property data is already loaded.
* NOT thread safe.
* @internal
*/
/*U_CFUNC int8_t
uprv_loadPropsData(UErrorCode *errorCode);*/
/**
* Type of a function that may be passed to the internal case mapping functions
* or similar for growing the destination buffer.
* @internal
*/
typedef UBool U_CALLCONV
UGrowBuffer(void *context, /* opaque pointer for this function */
UChar **pBuffer, /* in/out destination buffer pointer */
int32_t *pCapacity, /* in/out buffer capacity in numbers of UChars */
int32_t reqCapacity,/* requested capacity */
int32_t length); /* number of UChars to be copied to new buffer */
/**
* Default implementation of UGrowBuffer.
* Takes a static buffer as context, allocates a new buffer,
* and releases the old one if it is not the same as the one passed as context.
* @internal
*/
U_CAPI UBool /* U_CALLCONV U_EXPORT2 */
u_growBufferFromStatic(void *context,
UChar **pBuffer, int32_t *pCapacity, int32_t reqCapacity,
int32_t length);
/*
* Internal string casing functions implementing
* ustring.h/ustrcase.c and UnicodeString case mapping functions.
*/
/**
* @internal
*/
struct UCaseMap {
const UCaseProps *csp;
#if !UCONFIG_NO_BREAK_ITERATION
UBreakIterator *iter; /* We adopt the iterator, so we own it. */
#endif
char locale[32];
int32_t locCache;
uint32_t options;
};
#ifndef __UCASEMAP_H__
typedef struct UCaseMap UCaseMap;
#endif
/**
* @internal
*/
enum {
TO_LOWER,
TO_UPPER,
TO_TITLE,
FOLD_CASE
};
/**
* @internal
*/
U_CFUNC int32_t
ustr_toLower(const UCaseProps *csp,
UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
const char *locale,
UErrorCode *pErrorCode);
/**
* @internal
*/
U_CFUNC int32_t
ustr_toUpper(const UCaseProps *csp,
UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
const char *locale,
UErrorCode *pErrorCode);
#if !UCONFIG_NO_BREAK_ITERATION
/**
* @internal
*/
U_CFUNC int32_t
ustr_toTitle(const UCaseProps *csp,
UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
UBreakIterator *titleIter,
const char *locale, uint32_t options,
UErrorCode *pErrorCode);
#endif
/**
* Internal case folding function.
* @internal
*/
U_CFUNC int32_t
ustr_foldCase(const UCaseProps *csp,
UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
uint32_t options,
UErrorCode *pErrorCode);
/**
* NUL-terminate a UChar * string if possible.
* If length < destCapacity then NUL-terminate.
* If length == destCapacity then do not terminate but set U_STRING_NOT_TERMINATED_WARNING.
* If length > destCapacity then do not terminate but set U_BUFFER_OVERFLOW_ERROR.
*
* @param dest Destination buffer, can be NULL if destCapacity==0.
* @param destCapacity Number of UChars available at dest.
* @param length Number of UChars that were (to be) written to dest.
* @param pErrorCode ICU error code.
* @return length
* @internal
*/
U_CAPI int32_t U_EXPORT2
u_terminateUChars(UChar *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
/**
* NUL-terminate a char * string if possible.
* Same as u_terminateUChars() but for a different string type.
*/
U_CAPI int32_t U_EXPORT2
u_terminateChars(char *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
/**
* NUL-terminate a UChar32 * string if possible.
* Same as u_terminateUChars() but for a different string type.
*/
U_CAPI int32_t U_EXPORT2
u_terminateUChar32s(UChar32 *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
/**
* NUL-terminate a wchar_t * string if possible.
* Same as u_terminateUChars() but for a different string type.
*/
U_CAPI int32_t U_EXPORT2
u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
#endif
|