2 **********************************************************************
3 * Copyright (C) 1999-2010, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 * file name: ustr_imp.h
8 * tab size: 8 (not used)
11 * created on: 2001jan30
12 * created by: Markus W. Scherer
15 #ifndef __USTR_IMP_H__
16 #define __USTR_IMP_H__
18 #include "unicode/utypes.h"
19 #include "unicode/uiter.h"
22 /** Simple declaration for u_strToTitle() to avoid including unicode/ubrk.h. */
23 #ifndef UBRK_TYPEDEF_UBREAK_ITERATOR
24 # define UBRK_TYPEDEF_UBREAK_ITERATOR
25 typedef struct UBreakIterator UBreakIterator
;
28 #ifndef U_COMPARE_IGNORE_CASE
29 /* see also unorm.h */
31 * Option bit for unorm_compare:
32 * Perform case-insensitive comparison.
35 #define U_COMPARE_IGNORE_CASE 0x10000
39 * Internal option for unorm_cmpEquivFold() for strncmp style.
40 * If set, checks for both string length and terminating NUL.
43 #define _STRNCMP_STYLE 0x1000
46 * Compare two strings in code point order or code unit order.
47 * Works in strcmp style (both lengths -1),
48 * strncmp style (lengths equal and >=0, flag TRUE),
49 * and memcmp/UnicodeString style (at least one length >=0).
52 U_CFUNC
int32_t U_EXPORT2
53 uprv_strCompare(const UChar
*s1
, int32_t length1
,
54 const UChar
*s2
, int32_t length2
,
55 UBool strncmpStyle
, UBool codePointOrder
);
58 * Internal API, used by u_strcasecmp() etc.
59 * Compare strings case-insensitively,
60 * in code point order or code unit order.
64 u_strcmpFold(const UChar
*s1
, int32_t length1
,
65 const UChar
*s2
, int32_t length2
,
67 UErrorCode
*pErrorCode
);
70 * Are the Unicode properties loaded?
71 * This must be used before internal functions are called that do
72 * not perform this check.
73 * Generate a debug assertion failure if data is not loaded.
77 uprv_haveProperties(UErrorCode
*pErrorCode
);
80 * Load the Unicode property data.
81 * Intended primarily for use from u_init().
82 * Has no effect if property data is already loaded.
87 uprv_loadPropsData(UErrorCode *errorCode);*/
90 * Internal string casing functions implementing
91 * ustring.h/ustrcase.c and UnicodeString case mapping functions.
98 const UCaseProps
*csp
;
99 #if !UCONFIG_NO_BREAK_ITERATION
100 UBreakIterator
*iter
; /* We adopt the iterator, so we own it. */
107 #ifndef __UCASEMAP_H__
108 typedef struct UCaseMap UCaseMap
;
125 ustr_toLower(const UCaseProps
*csp
,
126 UChar
*dest
, int32_t destCapacity
,
127 const UChar
*src
, int32_t srcLength
,
129 UErrorCode
*pErrorCode
);
135 ustr_toUpper(const UCaseProps
*csp
,
136 UChar
*dest
, int32_t destCapacity
,
137 const UChar
*src
, int32_t srcLength
,
139 UErrorCode
*pErrorCode
);
141 #if !UCONFIG_NO_BREAK_ITERATION
147 ustr_toTitle(const UCaseProps
*csp
,
148 UChar
*dest
, int32_t destCapacity
,
149 const UChar
*src
, int32_t srcLength
,
150 UBreakIterator
*titleIter
,
151 const char *locale
, uint32_t options
,
152 UErrorCode
*pErrorCode
);
157 * Internal case folding function.
161 ustr_foldCase(const UCaseProps
*csp
,
162 UChar
*dest
, int32_t destCapacity
,
163 const UChar
*src
, int32_t srcLength
,
165 UErrorCode
*pErrorCode
);
168 * NUL-terminate a UChar * string if possible.
169 * If length < destCapacity then NUL-terminate.
170 * If length == destCapacity then do not terminate but set U_STRING_NOT_TERMINATED_WARNING.
171 * If length > destCapacity then do not terminate but set U_BUFFER_OVERFLOW_ERROR.
173 * @param dest Destination buffer, can be NULL if destCapacity==0.
174 * @param destCapacity Number of UChars available at dest.
175 * @param length Number of UChars that were (to be) written to dest.
176 * @param pErrorCode ICU error code.
180 U_CAPI
int32_t U_EXPORT2
181 u_terminateUChars(UChar
*dest
, int32_t destCapacity
, int32_t length
, UErrorCode
*pErrorCode
);
184 * NUL-terminate a char * string if possible.
185 * Same as u_terminateUChars() but for a different string type.
187 U_CAPI
int32_t U_EXPORT2
188 u_terminateChars(char *dest
, int32_t destCapacity
, int32_t length
, UErrorCode
*pErrorCode
);
191 * NUL-terminate a UChar32 * string if possible.
192 * Same as u_terminateUChars() but for a different string type.
194 U_CAPI
int32_t U_EXPORT2
195 u_terminateUChar32s(UChar32
*dest
, int32_t destCapacity
, int32_t length
, UErrorCode
*pErrorCode
);
198 * NUL-terminate a wchar_t * string if possible.
199 * Same as u_terminateUChars() but for a different string type.
201 U_CAPI
int32_t U_EXPORT2
202 u_terminateWChars(wchar_t *dest
, int32_t destCapacity
, int32_t length
, UErrorCode
*pErrorCode
);