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