]> git.saurik.com Git - apple/icu.git/blob - icuSources/common/ustr_imp.h
ICU-59173.0.1.tar.gz
[apple/icu.git] / icuSources / common / ustr_imp.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 **********************************************************************
5 * Copyright (C) 1999-2015, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
8 * file name: ustr_imp.h
9 * encoding: UTF-8
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 2001jan30
14 * created by: Markus W. Scherer
15 */
16
17 #ifndef __USTR_IMP_H__
18 #define __USTR_IMP_H__
19
20 #include "unicode/utypes.h"
21
22 /**
23 * Internal option for unorm_cmpEquivFold() for strncmp style.
24 * If set, checks for both string length and terminating NUL.
25 */
26 #define _STRNCMP_STYLE 0x1000
27
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 */
34 U_CFUNC int32_t U_EXPORT2
35 uprv_strCompare(const UChar *s1, int32_t length1,
36 const UChar *s2, int32_t length2,
37 UBool strncmpStyle, UBool codePointOrder);
38
39 U_CAPI int32_t U_EXPORT2
40 ustr_hashUCharsN(const UChar *str, int32_t length);
41
42 U_CAPI int32_t U_EXPORT2
43 ustr_hashCharsN(const char *str, int32_t length);
44
45 U_CAPI int32_t U_EXPORT2
46 ustr_hashICharsN(const char *str, int32_t length);
47
48 /**
49 * NUL-terminate a UChar * string if possible.
50 * If length < destCapacity then NUL-terminate.
51 * If length == destCapacity then do not terminate but set U_STRING_NOT_TERMINATED_WARNING.
52 * If length > destCapacity then do not terminate but set U_BUFFER_OVERFLOW_ERROR.
53 *
54 * @param dest Destination buffer, can be NULL if destCapacity==0.
55 * @param destCapacity Number of UChars available at dest.
56 * @param length Number of UChars that were (to be) written to dest.
57 * @param pErrorCode ICU error code.
58 * @return length
59 */
60 U_CAPI int32_t U_EXPORT2
61 u_terminateUChars(UChar *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
62
63 /**
64 * NUL-terminate a char * string if possible.
65 * Same as u_terminateUChars() but for a different string type.
66 */
67 U_CAPI int32_t U_EXPORT2
68 u_terminateChars(char *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
69
70 /**
71 * NUL-terminate a UChar32 * string if possible.
72 * Same as u_terminateUChars() but for a different string type.
73 */
74 U_CAPI int32_t U_EXPORT2
75 u_terminateUChar32s(UChar32 *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
76
77 /**
78 * NUL-terminate a wchar_t * string if possible.
79 * Same as u_terminateUChars() but for a different string type.
80 */
81 U_CAPI int32_t U_EXPORT2
82 u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
83
84 #endif