2 **********************************************************************
3 * Copyright (C) 1999-2011, 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.
34 #define U_COMPARE_IGNORE_CASE 0x10000
38 * Internal option for unorm_cmpEquivFold() for strncmp style.
39 * If set, checks for both string length and terminating NUL.
41 #define _STRNCMP_STYLE 0x1000
44 * Compare two strings in code point order or code unit order.
45 * Works in strcmp style (both lengths -1),
46 * strncmp style (lengths equal and >=0, flag TRUE),
47 * and memcmp/UnicodeString style (at least one length >=0).
49 U_CFUNC int32_t U_EXPORT2
50 uprv_strCompare(const UChar *s1, int32_t length1,
51 const UChar *s2, int32_t length2,
52 UBool strncmpStyle, UBool codePointOrder);
55 * Internal API, used by u_strcasecmp() etc.
56 * Compare strings case-insensitively,
57 * in code point order or code unit order.
60 u_strcmpFold(const UChar *s1, int32_t length1,
61 const UChar *s2, int32_t length2,
63 UErrorCode *pErrorCode);
66 * Are the Unicode properties loaded?
67 * This must be used before internal functions are called that do
68 * not perform this check.
69 * Generate a debug assertion failure if data is not loaded.
72 uprv_haveProperties(UErrorCode *pErrorCode);
75 * Load the Unicode property data.
76 * Intended primarily for use from u_init().
77 * Has no effect if property data is already loaded.
81 uprv_loadPropsData(UErrorCode *errorCode);*/
84 * Internal string casing functions implementing
85 * ustring.h/ustrcase.c and UnicodeString case mapping functions.
89 const UCaseProps *csp;
90 #if !UCONFIG_NO_BREAK_ITERATION
91 UBreakIterator *iter; /* We adopt the iterator, so we own it. */
98 #ifndef __UCASEMAP_H__
99 typedef struct UCaseMap UCaseMap;
110 ustr_toLower(const UCaseProps *csp,
111 UChar *dest, int32_t destCapacity,
112 const UChar *src, int32_t srcLength,
114 UErrorCode *pErrorCode);
117 ustr_toUpper(const UCaseProps *csp,
118 UChar *dest, int32_t destCapacity,
119 const UChar *src, int32_t srcLength,
121 UErrorCode *pErrorCode);
123 #if !UCONFIG_NO_BREAK_ITERATION
126 ustr_toTitle(const UCaseProps *csp,
127 UChar *dest, int32_t destCapacity,
128 const UChar *src, int32_t srcLength,
129 UBreakIterator *titleIter,
130 const char *locale, uint32_t options,
131 UErrorCode *pErrorCode);
136 * Internal case folding function.
139 ustr_foldCase(const UCaseProps *csp,
140 UChar *dest, int32_t destCapacity,
141 const UChar *src, int32_t srcLength,
143 UErrorCode *pErrorCode);
146 * NUL-terminate a UChar * string if possible.
147 * If length < destCapacity then NUL-terminate.
148 * If length == destCapacity then do not terminate but set U_STRING_NOT_TERMINATED_WARNING.
149 * If length > destCapacity then do not terminate but set U_BUFFER_OVERFLOW_ERROR.
151 * @param dest Destination buffer, can be NULL if destCapacity==0.
152 * @param destCapacity Number of UChars available at dest.
153 * @param length Number of UChars that were (to be) written to dest.
154 * @param pErrorCode ICU error code.
157 U_CAPI int32_t U_EXPORT2
158 u_terminateUChars(UChar *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
161 * NUL-terminate a char * string if possible.
162 * Same as u_terminateUChars() but for a different string type.
164 U_CAPI int32_t U_EXPORT2
165 u_terminateChars(char *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
168 * NUL-terminate a UChar32 * string if possible.
169 * Same as u_terminateUChars() but for a different string type.
171 U_CAPI int32_t U_EXPORT2
172 u_terminateUChar32s(UChar32 *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
175 * NUL-terminate a wchar_t * string if possible.
176 * Same as u_terminateUChars() but for a different string type.
178 U_CAPI int32_t U_EXPORT2
179 u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);