unistr.h revision 103e9ffba2cba345d0078eb8b8db33249f81840a
1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* 2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru********************************************************************** 3b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho* Copyright (C) 1998-2011, International Business Machines 4b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Corporation and others. All Rights Reserved. 5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru********************************************************************** 6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* File unistr.h 8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Modification History: 10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Date Name Description 12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 09/25/98 stephen Creation. 13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 11/11/98 stephen Changed per 11/9 code review. 14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 04/20/99 stephen Overhauled per 4/16 code review. 15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 11/18/99 aliu Made to inherit from Replaceable. Added method 16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* handleReplaceBetween(); other methods unchanged. 17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 06/25/01 grhoten Remove dependency on iostream. 18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru****************************************************************************** 19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/ 20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef UNISTR_H 22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UNISTR_H 23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \file 26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \brief C++ API: Unicode String 27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 28b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 29b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru#include "unicode/utypes.h" 30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/rep.h" 31b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru#include "unicode/std_string.h" 32b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru#include "unicode/stringpiece.h" 33b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru#include "unicode/bytestream.h" 34103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#include "unicode/ucasemap.h" 35b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 36b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustruct UConverter; // unicode/ucnv.h 37b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass StringThreadTest; 38b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 39b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef U_COMPARE_CODE_POINT_ORDER 40b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* see also ustring.h and unorm.h */ 41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc: 43b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare strings in code point order instead of code unit order. 44b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.2 45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 46b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define U_COMPARE_CODE_POINT_ORDER 0x8000 47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 49b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef USTRING_H 50b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 51b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \ingroup ustring_ustrlen 52b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2 54b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruu_strlen(const UChar *s); 55b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 56b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 57103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_STRING_CASE_MAPPER_DEFINED 58103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#define U_STRING_CASE_MAPPER_DEFINED 59103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius 60103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius/** 61103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * Internal string case mapping function type. 62103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @internal 63103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius */ 64103e9ffba2cba345d0078eb8b8db33249f81840aCraig Corneliustypedef int32_t U_CALLCONV 65103e9ffba2cba345d0078eb8b8db33249f81840aCraig CorneliusUStringCaseMapper(const UCaseMap *csm, 66103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UChar *dest, int32_t destCapacity, 67103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius const UChar *src, int32_t srcLength, 68103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UErrorCode *pErrorCode); 69103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius 70103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif 71103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius 72b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_NAMESPACE_BEGIN 73b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 74b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoclass BreakIterator; // unicode/brkiter.h 75b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass Locale; // unicode/locid.h 76b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass StringCharacterIterator; 77b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoclass UnicodeStringAppendable; // unicode/appendable.h 78b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 79b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* The <iostream> include has been moved to unicode/ustream.h */ 80b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 81b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 82b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor 83b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * which constructs a Unicode string from an invariant-character char * string. 84b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * About invariant characters see utypes.h. 85b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This constructor has no runtime dependency on conversion code and is 86b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * therefore recommended over ones taking a charset name string 87b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (where the empty string "" indicates invariant-character conversion). 88b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 89b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.2 90b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 91103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#define US_INV icu::UnicodeString::kInvariant 92b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 93b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 94b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Unicode String literals in C++. 95b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Dependent on the platform properties, different UnicodeString 96b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * constructors should be used to create a UnicodeString object from 97b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a string literal. 98b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The macros are defined for maximum performance. 99b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * They work only for strings that contain "invariant characters", i.e., 100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * only latin letters, digits, and some punctuation. 101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * See utypes.h for details. 102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The string parameter must be a C string literal. 104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The length of the string, not including the terminating 105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>NUL</code>, must be specified as a constant. 106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The U_STRING_DECL macro should be invoked exactly once for one 107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * such string variable before it is used. 108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if defined(U_DECLARE_UTF16) 111103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)U_DECLARE_UTF16(cs), _length) 112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16))) 113103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)L ## cs, _length) 114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY 115103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)cs, _length) 116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#else 117103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# define UNICODE_STRING(cs, _length) icu::UnicodeString(cs, _length, US_INV) 118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Unicode String literals in C++. 122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Dependent on the platform properties, different UnicodeString 123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * constructors should be used to create a UnicodeString object from 124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a string literal. 125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The macros are defined for improved performance. 126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * They work only for strings that contain "invariant characters", i.e., 127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * only latin letters, digits, and some punctuation. 128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * See utypes.h for details. 129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The string parameter must be a C string literal. 131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1) 134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 136103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * \def UNISTR_FROM_CHAR_EXPLICIT 137103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * This can be defined to be empty or "explicit". 138103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * If explicit, then the UnicodeString(UChar) and UnicodeString(UChar32) 139103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * constructors are marked as explicit, preventing their inadvertent use. 140103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @draft ICU 49 141103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius */ 142103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef UNISTR_FROM_CHAR_EXPLICIT 143103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) 144103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius // Auto-"explicit" in ICU library code. 145103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# define UNISTR_FROM_CHAR_EXPLICIT explicit 146103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# else 147103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius // Empty by default for source code compatibility. 148103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# define UNISTR_FROM_CHAR_EXPLICIT 149103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# endif 150103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif 151103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius 152103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius/** 153103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * \def UNISTR_FROM_STRING_EXPLICIT 154103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * This can be defined to be empty or "explicit". 155103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * If explicit, then the UnicodeString(const char *) and UnicodeString(const UChar *) 156103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * constructors are marked as explicit, preventing their inadvertent use. 157103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * 158103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * In particular, this helps prevent accidentally depending on ICU conversion code 159103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * by passing a string literal into an API with a const UnicodeString & parameter. 160103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @draft ICU 49 161103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius */ 162103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef UNISTR_FROM_STRING_EXPLICIT 163103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) 164103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius // Auto-"explicit" in ICU library code. 165103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# define UNISTR_FROM_STRING_EXPLICIT explicit 166103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# else 167103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius // Empty by default for source code compatibility. 168103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# define UNISTR_FROM_STRING_EXPLICIT 169103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius# endif 170103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif 171103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius 172103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius/** 173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UnicodeString is a string class that stores Unicode characters directly and provides 174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * similar functionality as the Java String and StringBuffer classes. 175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It is a concrete implementation of the abstract class Replaceable (for transliteration). 176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The UnicodeString class is not suitable for subclassing. 178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>For an overview of Unicode strings in C and C++ see the 180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <a href="http://icu-project.org/userguide/strings.html">User Guide Strings chapter</a>.</p> 181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>In ICU, a Unicode string consists of 16-bit Unicode <em>code units</em>. 183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * A Unicode character may be stored with either one code unit 184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (the most common case) or with a matched pair of special code units 185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * ("surrogates"). The data type for code units is UChar. 186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For single-character handling, a Unicode character code <em>point</em> is a value 187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the range 0..0x10ffff. ICU uses the UChar32 type for code points.</p> 188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>Indexes and offsets into and lengths of strings always count code units, not code points. 190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is the same as with multi-byte char* strings in traditional string handling. 191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Operations on partial strings typically do not test for code point boundaries. 192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If necessary, the user needs to take care of such boundaries by testing for the code unit 193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * values or by using functions like 194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UnicodeString::getChar32Start() and UnicodeString::getChar32Limit() 195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (or, in C, the equivalent macros U16_SET_CP_START() and U16_SET_CP_LIMIT(), see utf.h).</p> 196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UnicodeString methods are more lenient with regard to input parameter values 198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * than other ICU APIs. In particular: 199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - If indexes are out of bounds for a UnicodeString object 200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (<0 or >length()) then they are "pinned" to the nearest boundary. 201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - If primitive string pointer values (e.g., const UChar * or char *) 202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * for input strings are NULL, then those input string parameters are treated 203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * as if they pointed to an empty string. 204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * However, this is <em>not</em> the case for char * parameters for charset names 205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or other IDs. 206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - Most UnicodeString methods do not take a UErrorCode parameter because 207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * there are usually very few opportunities for failure other than a shortage 208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of memory, error codes in low-level C++ string methods would be inconvenient, 209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and the error code as the last parameter (ICU convention) would prevent 210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the use of default parameter values. 211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Instead, such methods set the UnicodeString into a "bogus" state 212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (see isBogus()) if an error occurs. 213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In string comparisons, two UnicodeString objects that are both "bogus" 215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * compare equal (to be transitive and prevent endless loops in sorting), 216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and a "bogus" string compares less than any non-"bogus" one. 217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Const UnicodeString methods are thread-safe. Multiple threads can use 219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * const methods on the same UnicodeString object simultaneously, 220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * but non-const methods must not be called concurrently (in multiple threads) 221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * with any other (const or non-const) methods. 222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Similarly, const UnicodeString & parameters are thread-safe. 224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * One object may be passed in as such a parameter concurrently in multiple threads. 225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This includes the const UnicodeString & parameters for 226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * copy construction, assignment, and cloning. 227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>UnicodeString uses several storage methods. 229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * String contents can be stored inside the UnicodeString object itself, 230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in an allocated and shared buffer, or in an outside buffer that is "aliased". 231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Most of this is done transparently, but careful aliasing in particular provides 232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * significant performance improvements. 233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Also, the internal buffer is accessible via special functions. 234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For details see the 235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <a href="http://icu-project.org/userguide/strings.html">User Guide Strings chapter</a>.</p> 236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see utf.h 238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see CharacterIterator 239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass U_COMMON_API UnicodeString : public Replaceable 242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querupublic: 244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor 247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * which constructs a Unicode string from an invariant-character char * string. 248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Use the macro US_INV instead of the full qualification for this value. 249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see US_INV 251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.2 252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru enum EInvariant { 254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see EInvariant 256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.2 257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru kInvariant 259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru }; 260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru //======================================== 262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // Read-only operations 263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru //======================================== 264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Comparison - bitwise only - for international comparison use collation */ 266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Equality operator. Performs only bitwise comparison. 269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The UnicodeString to compare to this one. 270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if <TT>text</TT> contains the same characters as this one, 271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * FALSE otherwise. 272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool operator== (const UnicodeString& text) const; 275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Inequality operator. Performs only bitwise comparison. 278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The UnicodeString to compare to this one. 279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return FALSE if <TT>text</TT> contains the same characters as this one, 280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * TRUE otherwise. 281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool operator!= (const UnicodeString& text) const; 284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Greater than operator. Performs only bitwise comparison. 287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The UnicodeString to compare to this one. 288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if the characters in this are bitwise 289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * greater than the characters in <code>text</code>, FALSE otherwise 290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool operator> (const UnicodeString& text) const; 293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Less than operator. Performs only bitwise comparison. 296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The UnicodeString to compare to this one. 297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if the characters in this are bitwise 298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * less than the characters in <code>text</code>, FALSE otherwise 299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool operator< (const UnicodeString& text) const; 302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Greater than or equal operator. Performs only bitwise comparison. 305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The UnicodeString to compare to this one. 306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if the characters in this are bitwise 307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * greater than or equal to the characters in <code>text</code>, FALSE otherwise 308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool operator>= (const UnicodeString& text) const; 311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Less than or equal operator. Performs only bitwise comparison. 314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The UnicodeString to compare to this one. 315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if the characters in this are bitwise 316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * less than or equal to the characters in <code>text</code>, FALSE otherwise 317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool operator<= (const UnicodeString& text) const; 320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare the characters bitwise in this UnicodeString to 323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the characters in <code>text</code>. 324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The UnicodeString to compare to this one. 325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The result of bitwise character comparison: 0 if this 326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * contains the same characters as <code>text</code>, -1 if the characters in 327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this are bitwise less than the characters in <code>text</code>, +1 if the 328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * characters in this are bitwise greater than the characters 329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <code>text</code>. 330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compare(const UnicodeString& text) const; 333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare the characters bitwise in the range 336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) with the characters 337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>text</TT> 338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the compare operation begins 339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters of text to compare. 340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text the other text to be compared against this string. 341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The result of bitwise character comparison: 0 if this 342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * contains the same characters as <code>text</code>, -1 if the characters in 343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this are bitwise less than the characters in <code>text</code>, +1 if the 344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * characters in this are bitwise greater than the characters 345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <code>text</code>. 346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compare(int32_t start, 349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& text) const; 351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare the characters bitwise in the range 354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) with the characters 355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcText</TT> in the range 356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>). 357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the compare operation begins 358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters in this to compare. 359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the text to be compared 360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcText</TT> to start comparison 361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>src</TT> to compare 362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The result of bitwise character comparison: 0 if this 363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * contains the same characters as <code>srcText</code>, -1 if the characters in 364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this are bitwise less than the characters in <code>srcText</code>, +1 if the 365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * characters in this are bitwise greater than the characters 366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <code>srcText</code>. 367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compare(int32_t start, 370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare the characters bitwise in this UnicodeString with the first 377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcLength</TT> characters in <TT>srcChars</TT>. 378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars The characters to compare to this UnicodeString. 379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> to compare 380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The result of bitwise character comparison: 0 if this 381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * contains the same characters as <code>srcChars</code>, -1 if the characters in 382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this are bitwise less than the characters in <code>srcChars</code>, +1 if the 383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * characters in this are bitwise greater than the characters 384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <code>srcChars</code>. 385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compare(const UChar *srcChars, 388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare the characters bitwise in the range 392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) with the first 393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>length</TT> characters in <TT>srcChars</TT> 394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the compare operation begins 395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters to compare. 396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars the characters to be compared 397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The result of bitwise character comparison: 0 if this 398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * contains the same characters as <code>srcChars</code>, -1 if the characters in 399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this are bitwise less than the characters in <code>srcChars</code>, +1 if the 400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * characters in this are bitwise greater than the characters 401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <code>srcChars</code>. 402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compare(int32_t start, 405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars) const; 407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare the characters bitwise in the range 410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) with the characters 411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcChars</TT> in the range 412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>). 413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the compare operation begins 414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters in this to compare 415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars the characters to be compared 416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcChars</TT> to start comparison 417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> to compare 418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The result of bitwise character comparison: 0 if this 419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * contains the same characters as <code>srcChars</code>, -1 if the characters in 420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this are bitwise less than the characters in <code>srcChars</code>, +1 if the 421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * characters in this are bitwise greater than the characters 422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <code>srcChars</code>. 423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compare(int32_t start, 426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare the characters bitwise in the range 433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>limit</TT>) with the characters 434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcText</TT> in the range 435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcLimit</TT>). 436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the compare operation begins 437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limit the offset immediately following the compare operation 438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the text to be compared 439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcText</TT> to start comparison 440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLimit the offset into <TT>srcText</TT> to limit comparison 441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The result of bitwise character comparison: 0 if this 442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * contains the same characters as <code>srcText</code>, -1 if the characters in 443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this are bitwise less than the characters in <code>srcText</code>, +1 if the 444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * characters in this are bitwise greater than the characters 445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <code>srcText</code>. 446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compareBetween(int32_t start, 449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLimit) const; 453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two Unicode strings in code point order. 456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The result may be different from the results of compare(), operator<, etc. 457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if supplementary characters are present: 458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In UTF-16, supplementary characters (with code points U+10000 and above) are 460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, 461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * which means that they compare as less than some other BMP characters like U+feff. 462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function compares Unicode strings in code point order. 463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. 464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text Another string to compare this one to. 466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a negative/zero/positive integer corresponding to whether 467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this string is less than/equal to/greater than the second one 468b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in code point order 469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compareCodePointOrder(const UnicodeString& text) const; 472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two Unicode strings in code point order. 475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The result may be different from the results of compare(), operator<, etc. 476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if supplementary characters are present: 477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In UTF-16, supplementary characters (with code points U+10000 and above) are 479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, 480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * which means that they compare as less than some other BMP characters like U+feff. 481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function compares Unicode strings in code point order. 482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. 483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The start offset in this string at which the compare operation begins. 485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The number of code units from this string to compare. 486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText Another string to compare this one to. 487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a negative/zero/positive integer corresponding to whether 488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this string is less than/equal to/greater than the second one 489b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in code point order 490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compareCodePointOrder(int32_t start, 493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText) const; 495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 497b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two Unicode strings in code point order. 498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The result may be different from the results of compare(), operator<, etc. 499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if supplementary characters are present: 500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In UTF-16, supplementary characters (with code points U+10000 and above) are 502b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, 503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * which means that they compare as less than some other BMP characters like U+feff. 504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function compares Unicode strings in code point order. 505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. 506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The start offset in this string at which the compare operation begins. 508b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The number of code units from this string to compare. 509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText Another string to compare this one to. 510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart The start offset in that string at which the compare operation begins. 511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength The number of code units from that string to compare. 512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a negative/zero/positive integer corresponding to whether 513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this string is less than/equal to/greater than the second one 514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in code point order 515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 516b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compareCodePointOrder(int32_t start, 518b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 519b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 524b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two Unicode strings in code point order. 525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The result may be different from the results of compare(), operator<, etc. 526b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if supplementary characters are present: 527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In UTF-16, supplementary characters (with code points U+10000 and above) are 529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, 530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * which means that they compare as less than some other BMP characters like U+feff. 531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function compares Unicode strings in code point order. 532b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. 533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 534b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars A pointer to another string to compare this one to. 535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength The number of code units from that string to compare. 536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a negative/zero/positive integer corresponding to whether 537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this string is less than/equal to/greater than the second one 538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in code point order 539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compareCodePointOrder(const UChar *srcChars, 542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two Unicode strings in code point order. 546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The result may be different from the results of compare(), operator<, etc. 547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if supplementary characters are present: 548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In UTF-16, supplementary characters (with code points U+10000 and above) are 550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, 551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * which means that they compare as less than some other BMP characters like U+feff. 552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function compares Unicode strings in code point order. 553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. 554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The start offset in this string at which the compare operation begins. 556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The number of code units from this string to compare. 557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars A pointer to another string to compare this one to. 558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a negative/zero/positive integer corresponding to whether 559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this string is less than/equal to/greater than the second one 560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in code point order 561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compareCodePointOrder(int32_t start, 564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars) const; 566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two Unicode strings in code point order. 569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The result may be different from the results of compare(), operator<, etc. 570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if supplementary characters are present: 571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In UTF-16, supplementary characters (with code points U+10000 and above) are 573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, 574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * which means that they compare as less than some other BMP characters like U+feff. 575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function compares Unicode strings in code point order. 576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. 577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The start offset in this string at which the compare operation begins. 579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The number of code units from this string to compare. 580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars A pointer to another string to compare this one to. 581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart The start offset in that string at which the compare operation begins. 582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength The number of code units from that string to compare. 583b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a negative/zero/positive integer corresponding to whether 584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this string is less than/equal to/greater than the second one 585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in code point order 586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compareCodePointOrder(int32_t start, 589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 590b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 595b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two Unicode strings in code point order. 596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The result may be different from the results of compare(), operator<, etc. 597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if supplementary characters are present: 598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In UTF-16, supplementary characters (with code points U+10000 and above) are 600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, 601b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * which means that they compare as less than some other BMP characters like U+feff. 602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function compares Unicode strings in code point order. 603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. 604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 605b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The start offset in this string at which the compare operation begins. 606b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limit The offset after the last code unit from this string to compare. 607b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText Another string to compare this one to. 608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart The start offset in that string at which the compare operation begins. 609b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLimit The offset after the last code unit from that string to compare. 610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a negative/zero/positive integer corresponding to whether 611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this string is less than/equal to/greater than the second one 612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in code point order 613b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 614b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 615b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t compareCodePointOrderBetween(int32_t start, 616b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLimit) const; 620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 622b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two strings case-insensitively using full case folding. 623b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is equivalent to this->foldCase(options).compare(text.foldCase(options)). 624b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 625b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text Another string to compare this one to. 626b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options A bit set of options: 627b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_DEFAULT or 0 is used for default options: 628b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Comparison in code unit order with default case folding. 629b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 630b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_COMPARE_CODE_POINT_ORDER 631b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set to choose code point order instead of code unit order 632b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (see u_strCompare for details). 633b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 634b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_EXCLUDE_SPECIAL_I 635b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 636b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A negative, zero, or positive integer indicating the comparison result. 637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t caseCompare(const UnicodeString& text, uint32_t options) const; 640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 642b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two strings case-insensitively using full case folding. 643b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)). 644b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 645b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The start offset in this string at which the compare operation begins. 646b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The number of code units from this string to compare. 647b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText Another string to compare this one to. 648b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options A bit set of options: 649b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_DEFAULT or 0 is used for default options: 650b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Comparison in code unit order with default case folding. 651b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 652b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_COMPARE_CODE_POINT_ORDER 653b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set to choose code point order instead of code unit order 654b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (see u_strCompare for details). 655b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 656b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_EXCLUDE_SPECIAL_I 657b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 658b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A negative, zero, or positive integer indicating the comparison result. 659b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 660b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 661b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t caseCompare(int32_t start, 662b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 663b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 664b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const; 665b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 666b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 667b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two strings case-insensitively using full case folding. 668b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)). 669b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 670b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The start offset in this string at which the compare operation begins. 671b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The number of code units from this string to compare. 672b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText Another string to compare this one to. 673b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart The start offset in that string at which the compare operation begins. 674b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength The number of code units from that string to compare. 675b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options A bit set of options: 676b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_DEFAULT or 0 is used for default options: 677b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Comparison in code unit order with default case folding. 678b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 679b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_COMPARE_CODE_POINT_ORDER 680b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set to choose code point order instead of code unit order 681b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (see u_strCompare for details). 682b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_EXCLUDE_SPECIAL_I 684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A negative, zero, or positive integer indicating the comparison result. 686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 687b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 688b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t caseCompare(int32_t start, 689b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 690b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 691b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 692b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 693b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const; 694b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 695b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 696b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two strings case-insensitively using full case folding. 697b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)). 698b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 699b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars A pointer to another string to compare this one to. 700b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength The number of code units from that string to compare. 701b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options A bit set of options: 702b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_DEFAULT or 0 is used for default options: 703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Comparison in code unit order with default case folding. 704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_COMPARE_CODE_POINT_ORDER 706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set to choose code point order instead of code unit order 707b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (see u_strCompare for details). 708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 709b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_EXCLUDE_SPECIAL_I 710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A negative, zero, or positive integer indicating the comparison result. 712b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t caseCompare(const UChar *srcChars, 715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const; 717b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 718b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 719b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two strings case-insensitively using full case folding. 720b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)). 721b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 722b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The start offset in this string at which the compare operation begins. 723b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The number of code units from this string to compare. 724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars A pointer to another string to compare this one to. 725b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options A bit set of options: 726b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_DEFAULT or 0 is used for default options: 727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Comparison in code unit order with default case folding. 728b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 729b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_COMPARE_CODE_POINT_ORDER 730b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set to choose code point order instead of code unit order 731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (see u_strCompare for details). 732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_EXCLUDE_SPECIAL_I 734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 735b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A negative, zero, or positive integer indicating the comparison result. 736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 737b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 738b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t caseCompare(int32_t start, 739b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 740b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 741b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const; 742b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 743b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 744b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two strings case-insensitively using full case folding. 745b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)). 746b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 747b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The start offset in this string at which the compare operation begins. 748b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The number of code units from this string to compare. 749b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars A pointer to another string to compare this one to. 750b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart The start offset in that string at which the compare operation begins. 751b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength The number of code units from that string to compare. 752b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options A bit set of options: 753b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_DEFAULT or 0 is used for default options: 754b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Comparison in code unit order with default case folding. 755b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 756b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_COMPARE_CODE_POINT_ORDER 757b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set to choose code point order instead of code unit order 758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (see u_strCompare for details). 759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 760b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_EXCLUDE_SPECIAL_I 761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A negative, zero, or positive integer indicating the comparison result. 763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 765b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t caseCompare(int32_t start, 766b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 767b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 768b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 769b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 770b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const; 771b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 772b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 773b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two strings case-insensitively using full case folding. 774b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is equivalent to this->foldCase(options).compareBetween(text.foldCase(options)). 775b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 776b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The start offset in this string at which the compare operation begins. 777b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limit The offset after the last code unit from this string to compare. 778b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText Another string to compare this one to. 779b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart The start offset in that string at which the compare operation begins. 780b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLimit The offset after the last code unit from that string to compare. 781b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options A bit set of options: 782b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_DEFAULT or 0 is used for default options: 783b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Comparison in code unit order with default case folding. 784b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 785b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_COMPARE_CODE_POINT_ORDER 786b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set to choose code point order instead of code unit order 787b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (see u_strCompare for details). 788b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 789b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - U_FOLD_CASE_EXCLUDE_SPECIAL_I 790b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 791b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A negative, zero, or positive integer indicating the comparison result. 792b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 793b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 794b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t caseCompareBetween(int32_t start, 795b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 796b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 797b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 798b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLimit, 799b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const; 800b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 801b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 802b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Determine if this starts with the characters in <TT>text</TT> 803b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The text to match. 804b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if this starts with the characters in <TT>text</TT>, 805b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * FALSE otherwise 806b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 807b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 808b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool startsWith(const UnicodeString& text) const; 809b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 810b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 811b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Determine if this starts with the characters in <TT>srcText</TT> 812b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>). 813b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText The text to match. 814b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcText</TT> to start matching 815b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcText</TT> to match 816b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if this starts with the characters in <TT>text</TT>, 817b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * FALSE otherwise 818b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 819b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 820b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool startsWith(const UnicodeString& srcText, 821b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 822b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 823b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 824b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 825b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Determine if this starts with the characters in <TT>srcChars</TT> 826b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars The characters to match. 827b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> 828b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if this starts with the characters in <TT>srcChars</TT>, 829b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * FALSE otherwise 830b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 831b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 832b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool startsWith(const UChar *srcChars, 833b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 834b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 835b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 836b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Determine if this ends with the characters in <TT>srcChars</TT> 837b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>). 838b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars The characters to match. 839b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcText</TT> to start matching 840b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> to match 841b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if this ends with the characters in <TT>srcChars</TT>, FALSE otherwise 842b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 843b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 844b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool startsWith(const UChar *srcChars, 845b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 846b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 847b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 848b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 849b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Determine if this ends with the characters in <TT>text</TT> 850b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The text to match. 851b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if this ends with the characters in <TT>text</TT>, 852b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * FALSE otherwise 853b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 854b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 855b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool endsWith(const UnicodeString& text) const; 856b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 857b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 858b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Determine if this ends with the characters in <TT>srcText</TT> 859b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>). 860b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText The text to match. 861b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcText</TT> to start matching 862b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcText</TT> to match 863b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if this ends with the characters in <TT>text</TT>, 864b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * FALSE otherwise 865b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 866b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 867b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool endsWith(const UnicodeString& srcText, 868b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 869b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 870b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 871b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 872b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Determine if this ends with the characters in <TT>srcChars</TT> 873b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars The characters to match. 874b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> 875b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if this ends with the characters in <TT>srcChars</TT>, 876b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * FALSE otherwise 877b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 878b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 879b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool endsWith(const UChar *srcChars, 880b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 881b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 882b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 883b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Determine if this ends with the characters in <TT>srcChars</TT> 884b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>). 885b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars The characters to match. 886b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcText</TT> to start matching 887b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> to match 888b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if this ends with the characters in <TT>srcChars</TT>, 889b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * FALSE otherwise 890b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 891b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 892b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool endsWith(const UChar *srcChars, 893b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 894b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 895b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 896b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 897b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Searching - bitwise only */ 898b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 899b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 900b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the first occurrence of the characters in <TT>text</TT>, 901b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 902b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The text to search for. 903b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>text</TT>, 904b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 905b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 906b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 907b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t indexOf(const UnicodeString& text) const; 908b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 909b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 910b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the first occurrence of the characters in <TT>text</TT> 911b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * starting at offset <TT>start</TT>, using bitwise comparison. 912b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The text to search for. 913b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The offset at which searching will start. 914b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>text</TT>, 915b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 916b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 917b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 918b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t indexOf(const UnicodeString& text, 919b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const; 920b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 921b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 922b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the first occurrence in the range 923b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) of the characters 924b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>text</TT>, using bitwise comparison. 925b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The text to search for. 926b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The offset at which searching will start. 927b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The number of characters to search 928b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>text</TT>, 929b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 930b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 931b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 932b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t indexOf(const UnicodeString& text, 933b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 934b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 935b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 936b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 937b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the first occurrence in the range 938b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) of the characters 939b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcText</TT> in the range 940b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>), 941b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 942b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText The text to search for. 943b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcText</TT> at which 944b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to start matching 945b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcText</TT> to match 946b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset into this at which to start matching 947b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters in this to search 948b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>text</TT>, 949b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 950b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 951b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 952b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t indexOf(const UnicodeString& srcText, 953b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 954b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 955b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 956b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 957b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 958b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 959b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the first occurrence of the characters in 960b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcChars</TT> 961b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * starting at offset <TT>start</TT>, using bitwise comparison. 962b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars The text to search for. 963b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> to match 964b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset into this at which to start matching 965b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>text</TT>, 966b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 967b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 968b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 969b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t indexOf(const UChar *srcChars, 970b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 971b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const; 972b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 973b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 974b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the first occurrence in the range 975b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) of the characters 976b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcChars</TT>, using bitwise comparison. 977b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars The text to search for. 978b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> 979b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The offset at which searching will start. 980b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The number of characters to search 981b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>srcChars</TT>, 982b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 983b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 984b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 985b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t indexOf(const UChar *srcChars, 986b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 987b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 988b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 989b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 990b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 991b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the first occurrence in the range 992b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) of the characters 993b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcChars</TT> in the range 994b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>), 995b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 996b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars The text to search for. 997b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcChars</TT> at which 998b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to start matching 999b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> to match 1000b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset into this at which to start matching 1001b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters in this to search 1002b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>text</TT>, 1003b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 1004b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1005b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1006b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t indexOf(const UChar *srcChars, 1007b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 1008b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 1009b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 1010b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 1011b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1012b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1013b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the first occurrence of the BMP code point <code>c</code>, 1014b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 1015b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c The code unit to search for. 1016b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of <TT>c</TT>, or -1 if not found. 1017b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1018b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1019b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t indexOf(UChar c) const; 1020b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1021b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1022b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the first occurrence of the code point <TT>c</TT>, 1023b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 1024b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1025b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c The code point to search for. 1026b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of <TT>c</TT>, or -1 if not found. 1027b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1028b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1029b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t indexOf(UChar32 c) const; 1030b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1031b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1032b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the first occurrence of the BMP code point <code>c</code>, 1033b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * starting at offset <TT>start</TT>, using bitwise comparison. 1034b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c The code unit to search for. 1035b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The offset at which searching will start. 1036b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of <TT>c</TT>, or -1 if not found. 1037b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1038b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1039b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t indexOf(UChar c, 1040b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const; 1041b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1042b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1043b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the first occurrence of the code point <TT>c</TT> 1044b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * starting at offset <TT>start</TT>, using bitwise comparison. 1045b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1046b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c The code point to search for. 1047b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The offset at which searching will start. 1048b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of <TT>c</TT>, or -1 if not found. 1049b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1050b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1051b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t indexOf(UChar32 c, 1052b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const; 1053b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1054b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1055b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the first occurrence of the BMP code point <code>c</code> 1056b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the range [<TT>start</TT>, <TT>start + length</TT>), 1057b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 1058b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c The code unit to search for. 1059b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset into this at which to start matching 1060b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters in this to search 1061b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of <TT>c</TT>, or -1 if not found. 1062b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1063b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1064b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t indexOf(UChar c, 1065b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 1066b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 1067b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1068b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1069b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the first occurrence of the code point <TT>c</TT> 1070b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the range [<TT>start</TT>, <TT>start + length</TT>), 1071b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 1072b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1073b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c The code point to search for. 1074b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset into this at which to start matching 1075b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters in this to search 1076b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of <TT>c</TT>, or -1 if not found. 1077b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1078b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1079b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t indexOf(UChar32 c, 1080b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 1081b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 1082b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1083b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1084b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the last occurrence of the characters in <TT>text</TT>, 1085b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 1086b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The text to search for. 1087b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>text</TT>, 1088b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 1089b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1090b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1091b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t lastIndexOf(const UnicodeString& text) const; 1092b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1093b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1094b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the last occurrence of the characters in <TT>text</TT> 1095b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * starting at offset <TT>start</TT>, using bitwise comparison. 1096b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The text to search for. 1097b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The offset at which searching will start. 1098b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>text</TT>, 1099b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 1100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t lastIndexOf(const UnicodeString& text, 1103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const; 1104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the last occurrence in the range 1107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) of the characters 1108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>text</TT>, using bitwise comparison. 1109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The text to search for. 1110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The offset at which searching will start. 1111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The number of characters to search 1112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>text</TT>, 1113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 1114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t lastIndexOf(const UnicodeString& text, 1117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 1118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 1119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the last occurrence in the range 1122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) of the characters 1123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcText</TT> in the range 1124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>), 1125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 1126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText The text to search for. 1127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcText</TT> at which 1128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to start matching 1129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcText</TT> to match 1130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset into this at which to start matching 1131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters in this to search 1132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>text</TT>, 1133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 1134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t lastIndexOf(const UnicodeString& srcText, 1137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 1138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 1139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 1140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 1141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the last occurrence of the characters in <TT>srcChars</TT> 1144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * starting at offset <TT>start</TT>, using bitwise comparison. 1145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars The text to search for. 1146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> to match 1147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset into this at which to start matching 1148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>text</TT>, 1149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 1150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t lastIndexOf(const UChar *srcChars, 1153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 1154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const; 1155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the last occurrence in the range 1158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) of the characters 1159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcChars</TT>, using bitwise comparison. 1160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars The text to search for. 1161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> 1162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The offset at which searching will start. 1163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The number of characters to search 1164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>srcChars</TT>, 1165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 1166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t lastIndexOf(const UChar *srcChars, 1169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 1170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 1171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 1172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the last occurrence in the range 1175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) of the characters 1176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcChars</TT> in the range 1177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>), 1178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 1179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars The text to search for. 1180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcChars</TT> at which 1181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to start matching 1182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> to match 1183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset into this at which to start matching 1184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters in this to search 1185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of the start of <TT>text</TT>, 1186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or -1 if not found. 1187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t lastIndexOf(const UChar *srcChars, 1190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 1191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 1192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 1193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 1194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the last occurrence of the BMP code point <code>c</code>, 1197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 1198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c The code unit to search for. 1199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of <TT>c</TT>, or -1 if not found. 1200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t lastIndexOf(UChar c) const; 1203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the last occurrence of the code point <TT>c</TT>, 1206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 1207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c The code point to search for. 1209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of <TT>c</TT>, or -1 if not found. 1210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t lastIndexOf(UChar32 c) const; 1213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the last occurrence of the BMP code point <code>c</code> 1216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * starting at offset <TT>start</TT>, using bitwise comparison. 1217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c The code unit to search for. 1218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The offset at which searching will start. 1219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of <TT>c</TT>, or -1 if not found. 1220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t lastIndexOf(UChar c, 1223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const; 1224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the last occurrence of the code point <TT>c</TT> 1227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * starting at offset <TT>start</TT>, using bitwise comparison. 1228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c The code point to search for. 1230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start The offset at which searching will start. 1231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of <TT>c</TT>, or -1 if not found. 1232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t lastIndexOf(UChar32 c, 1235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const; 1236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the last occurrence of the BMP code point <code>c</code> 1239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the range [<TT>start</TT>, <TT>start + length</TT>), 1240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 1241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c The code unit to search for. 1242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset into this at which to start matching 1243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters in this to search 1244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of <TT>c</TT>, or -1 if not found. 1245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t lastIndexOf(UChar c, 1248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 1249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 1250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Locate in this the last occurrence of the code point <TT>c</TT> 1253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the range [<TT>start</TT>, <TT>start + length</TT>), 1254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using bitwise comparison. 1255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c The code point to search for. 1257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset into this at which to start matching 1258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters in this to search 1259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The offset into this of <TT>c</TT>, or -1 if not found. 1260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t lastIndexOf(UChar32 c, 1263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 1264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 1265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Character access */ 1268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Return the code unit at offset <tt>offset</tt>. 1271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the offset is not valid (0..length()-1) then U+ffff is returned. 1272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param offset a valid offset into the text 1273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the code unit at offset <tt>offset</tt> 1274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or 0xffff if the offset is not valid for this string 1275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UChar charAt(int32_t offset) const; 1278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Return the code unit at offset <tt>offset</tt>. 1281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the offset is not valid (0..length()-1) then U+ffff is returned. 1282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param offset a valid offset into the text 1283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the code unit at offset <tt>offset</tt> 1284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UChar operator[] (int32_t offset) const; 1287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Return the code point that contains the code unit 1290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * at offset <tt>offset</tt>. 1291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the offset is not valid (0..length()-1) then U+ffff is returned. 1292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param offset a valid offset into the text 1293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that indicates the text offset of any of the code units 1294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that will be assembled into a code point (21-bit value) and returned 1295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the code point of text at <tt>offset</tt> 1296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or 0xffff if the offset is not valid for this string 1297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1299103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UChar32 char32At(int32_t offset) const; 1300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Adjust a random-access offset so that 1303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * it points to the beginning of a Unicode character. 1304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The offset that is passed in points to 1305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * any code unit of a code point, 1306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * while the returned offset will point to the first code unit 1307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of the same code point. 1308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In UTF-16, if the input offset points to a second surrogate 1309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of a surrogate pair, then the returned offset will point 1310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to the first surrogate. 1311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param offset a valid offset into one code point of the text 1312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return offset of the first code unit of the same code point 1313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see U16_SET_CP_START 1314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1316103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius int32_t getChar32Start(int32_t offset) const; 1317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Adjust a random-access offset so that 1320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * it points behind a Unicode character. 1321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The offset that is passed in points behind 1322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * any code unit of a code point, 1323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * while the returned offset will point behind the last code unit 1324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of the same code point. 1325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In UTF-16, if the input offset points behind the first surrogate 1326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (i.e., to the second surrogate) 1327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of a surrogate pair, then the returned offset will point 1328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * behind the second surrogate (i.e., to the first surrogate). 1329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param offset a valid offset after any code unit of a code point of the text 1330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return offset of the first code unit after the same code point 1331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see U16_SET_CP_LIMIT 1332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1334103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius int32_t getChar32Limit(int32_t offset) const; 1335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Move the code unit index along the string by delta code points. 1338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Interpret the input index as a code unit-based offset into the string, 1339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * move the index forward or backward by delta code points, and 1340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * return the resulting index. 1341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The input index should point to the first code unit of a code point, 1342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if there is more than one. 1343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Both input and output indexes are code unit-based as for all 1345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * string indexes/offsets in ICU (and other libraries, like MBCS char*). 1346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If delta<0 then the index is moved backward (toward the start of the string). 1347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If delta>0 then the index is moved forward (toward the end of the string). 1348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This behaves like CharacterIterator::move32(delta, kCurrent). 1350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Behavior for out-of-bounds indexes: 1352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>moveIndex32</code> pins the input index to 0..length(), i.e., 1353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if the input index<0 then it is pinned to 0; 1354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if it is index>length() then it is pinned to length(). 1355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Afterwards, the index is moved by <code>delta</code> code points 1356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * forward or backward, 1357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * but no further backward than to 0 and no further forward than to length(). 1358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The resulting index return value will be in between 0 and length(), inclusively. 1359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Examples: 1361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <pre> 1362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * // s has code points 'a' U+10000 'b' U+10ffff U+2029 1363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UnicodeString s=UNICODE_STRING("a\\U00010000b\\U0010ffff\\u2029", 31).unescape(); 1364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * // initial index: position of U+10000 1366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * int32_t index=1; 1367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * // the following examples will all result in index==4, position of U+10ffff 1369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * // skip 2 code points from some position in the string 1371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * index=s.moveIndex32(index, 2); // skips U+10000 and 'b' 1372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * // go to the 3rd code point from the start of s (0-based) 1374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * index=s.moveIndex32(0, 3); // skips 'a', U+10000, and 'b' 1375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * // go to the next-to-last code point of s 1377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * index=s.moveIndex32(s.length(), -2); // backward-skips U+2029 and U+10ffff 1378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * </pre> 1379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param index input code unit index 1381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param delta (signed) code point count to move the index forward or backward 1382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the string 1383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the resulting code unit index 1384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t moveIndex32(int32_t index, int32_t delta) const; 1387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Substring extraction */ 1389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy the characters in the range 1392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<tt>start</tt>, <tt>start + length</tt>) into the array <tt>dst</tt>, 1393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * beginning at <tt>dstStart</tt>. 1394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the string aliases to <code>dst</code> itself as an external buffer, 1395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * then extract() will not copy the contents. 1396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start offset of first character which will be copied into the array 1398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters to extract 1399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dst array in which to copy characters. The length of <tt>dst</tt> 1400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * must be at least (<tt>dstStart + length</tt>). 1401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dstStart the offset in <TT>dst</TT> where the first character 1402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be extracted 1403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline void extract(int32_t start, 1406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 1407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar *dst, 1408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t dstStart = 0) const; 1409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy the contents of the string into dest. 1412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is a convenience function that 1413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * checks if there is enough space in dest, 1414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * extracts the entire string if possible, 1415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and NUL-terminates dest if possible. 1416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the string fits into dest but cannot be NUL-terminated 1418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (length()==destCapacity) then the error code is set to U_STRING_NOT_TERMINATED_WARNING. 1419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the string itself does not fit into dest 1420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (length()>destCapacity) then the error code is set to U_BUFFER_OVERFLOW_ERROR. 1421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the string aliases to <code>dest</code> itself as an external buffer, 1423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * then extract() will not copy the contents. 1424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest Destination string buffer. 1426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destCapacity Number of UChars available at dest. 1427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param errorCode ICU error code. 1428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return length() 1429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t 1432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru extract(UChar *dest, int32_t destCapacity, 1433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode &errorCode) const; 1434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy the characters in the range 1437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<tt>start</tt>, <tt>start + length</tt>) into the UnicodeString 1438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <tt>target</tt>. 1439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start offset of first character which will be copied 1440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters to extract 1441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param target UnicodeString into which to copy characters. 1442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A reference to <TT>target</TT> 1443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline void extract(int32_t start, 1446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 1447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& target) const; 1448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>) 1451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * into the array <tt>dst</tt>, beginning at <tt>dstStart</tt>. 1452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start offset of first character which will be copied into the array 1453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limit offset immediately following the last character to be copied 1454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dst array in which to copy characters. The length of <tt>dst</tt> 1455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * must be at least (<tt>dstStart + (limit - start)</tt>). 1456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dstStart the offset in <TT>dst</TT> where the first character 1457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be extracted 1458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline void extractBetween(int32_t start, 1461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 1462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar *dst, 1463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t dstStart = 0) const; 1464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>) 1467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * into the UnicodeString <tt>target</tt>. Replaceable API. 1468b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start offset of first character which will be copied 1469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limit offset immediately following the last character to be copied 1470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param target UnicodeString into which to copy characters. 1471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A reference to <TT>target</TT> 1472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual void extractBetween(int32_t start, 1475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 1476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& target) const; 1477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy the characters in the range 1480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters. 1481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * All characters must be invariant (see utypes.h). 1482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Use US_INV as the last, signature-distinguishing parameter. 1483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function does not write any more than <code>targetLength</code> 1485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * characters but returns the length of the entire output string 1486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * so that one can allocate a larger buffer and call the function again 1487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if necessary. 1488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The output string is NUL-terminated if possible. 1489b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start offset of first character which will be copied 1491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param startLength the number of characters to extract 1492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param target the target buffer for extraction, can be NULL 1493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if targetLength is 0 1494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param targetCapacity the length of the target buffer 1495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param inv Signature-distinguishing paramater, use US_INV. 1496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the output string length, not including the terminating NUL 1497b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.2 1498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t extract(int32_t start, 1500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t startLength, 1501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru char *target, 1502b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t targetCapacity, 1503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru enum EInvariant inv) const; 1504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1505b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru#if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION 1506b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 1507b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru /** 1508b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Copy the characters in the range 1509b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters 1510b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * in the platform's default codepage. 1511b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * This function does not write any more than <code>targetLength</code> 1512b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * characters but returns the length of the entire output string 1513b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * so that one can allocate a larger buffer and call the function again 1514b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * if necessary. 1515b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * The output string is NUL-terminated if possible. 1516b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * 1517b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param start offset of first character which will be copied 1518b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param startLength the number of characters to extract 1519b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param target the target buffer for extraction 1520b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param targetLength the length of the target buffer 1521b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * If <TT>target</TT> is NULL, then the number of bytes required for 1522b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * <TT>target</TT> is returned. 1523b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @return the output string length, not including the terminating NUL 1524b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @stable ICU 2.0 1525b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru */ 1526b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru int32_t extract(int32_t start, 1527b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru int32_t startLength, 1528b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru char *target, 1529b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru uint32_t targetLength) const; 1530b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 1531b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru#endif 1532b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 1533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_CONVERSION 1534b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy the characters in the range 1537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters 1538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in a specified codepage. 1539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The output string is NUL-terminated. 1540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Recommendation: For invariant-character strings use 1542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * extract(int32_t start, int32_t length, char *target, int32_t targetCapacity, enum EInvariant inv) const 1543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * because it avoids object code dependencies of UnicodeString on 1544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the conversion code. 1545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start offset of first character which will be copied 1547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param startLength the number of characters to extract 1548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param target the target buffer for extraction 1549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param codepage the desired codepage for the characters. 0 has 1550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the special meaning of the default codepage 1551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If <code>codepage</code> is an empty string (<code>""</code>), 1552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * then a simple conversion is performed on the codepage-invariant 1553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * subset ("invariant characters") of the platform encoding. See utypes.h. 1554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If <TT>target</TT> is NULL, then the number of bytes required for 1555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>target</TT> is returned. It is assumed that the target is big enough 1556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to fit all of the characters. 1557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the output string length, not including the terminating NUL 1558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t extract(int32_t start, 1561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t startLength, 1562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru char *target, 1563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const char *codepage = 0) const; 1564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy the characters in the range 1567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters 1568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in a specified codepage. 1569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function does not write any more than <code>targetLength</code> 1570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * characters but returns the length of the entire output string 1571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * so that one can allocate a larger buffer and call the function again 1572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if necessary. 1573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The output string is NUL-terminated if possible. 1574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Recommendation: For invariant-character strings use 1576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * extract(int32_t start, int32_t length, char *target, int32_t targetCapacity, enum EInvariant inv) const 1577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * because it avoids object code dependencies of UnicodeString on 1578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the conversion code. 1579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start offset of first character which will be copied 1581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param startLength the number of characters to extract 1582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param target the target buffer for extraction 1583b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param targetLength the length of the target buffer 1584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param codepage the desired codepage for the characters. 0 has 1585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the special meaning of the default codepage 1586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If <code>codepage</code> is an empty string (<code>""</code>), 1587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * then a simple conversion is performed on the codepage-invariant 1588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * subset ("invariant characters") of the platform encoding. See utypes.h. 1589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If <TT>target</TT> is NULL, then the number of bytes required for 1590b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>target</TT> is returned. 1591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the output string length, not including the terminating NUL 1592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t extract(int32_t start, 1595b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t startLength, 1596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru char *target, 1597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t targetLength, 1598b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru const char *codepage) const; 1599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1601b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Convert the UnicodeString into a codepage string using an existing UConverter. 1602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The output string is NUL-terminated if possible. 1603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function avoids the overhead of opening and closing a converter if 1605b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * multiple strings are extracted. 1606b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1607b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest destination string buffer, can be NULL if destCapacity==0 1608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destCapacity the number of chars available at dest 1609b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param cnv the converter object to be used (ucnv_resetFromUnicode() will be called), 1610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or NULL for the default converter 1611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param errorCode normal ICU error code 1612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the length of the output string, not counting the terminating NUL; 1613b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if the length is greater than destCapacity, then the string will not fit 1614b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and a buffer of the indicated length would need to be passed in 1615b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1616b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t extract(char *dest, int32_t destCapacity, 1618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UConverter *cnv, 1619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode &errorCode) const; 1620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 1622b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1623b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru /** 162450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Create a temporary substring for the specified range. 162550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Unlike the substring constructor and setTo() functions, 162650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * the object returned here will be a read-only alias (using getBuffer()) 162750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * rather than copying the text. 162850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * As a result, this substring operation is much faster but requires 162950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * that the original string not be modified or deleted during the lifetime 163050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * of the returned substring object. 163150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param start offset of the first character visible in the substring 163250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param length length of the substring 163350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return a read-only alias UnicodeString object for the substring 163427f654740f2a26ad62a5c155af9199af9e69b889claireho * @stable ICU 4.4 163550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 163650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UnicodeString tempSubString(int32_t start=0, int32_t length=INT32_MAX) const; 163750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 163850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho /** 163950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Create a temporary substring for the specified range. 164050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Same as tempSubString(start, length) except that the substring range 164150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * is specified as a (start, limit) pair (with an exclusive limit index) 164250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * rather than a (start, length) pair. 164350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param start offset of the first character visible in the substring 164450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param limit offset immediately following the last character visible in the substring 164550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return a read-only alias UnicodeString object for the substring 164627f654740f2a26ad62a5c155af9199af9e69b889claireho * @stable ICU 4.4 164750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 164850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho inline UnicodeString tempSubStringBetween(int32_t start, int32_t limit=INT32_MAX) const; 164950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 165050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho /** 1651b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Convert the UnicodeString to UTF-8 and write the result 1652b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * to a ByteSink. This is called by toUTF8String(). 1653b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Unpaired surrogates are replaced with U+FFFD. 1654b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Calls u_strToUTF8WithSub(). 1655b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * 1656b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param sink A ByteSink to which the UTF-8 version of the string is written. 165727f654740f2a26ad62a5c155af9199af9e69b889claireho * sink.Flush() is called at the end. 165850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @stable ICU 4.2 1659b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @see toUTF8String 1660b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru */ 1661b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru void toUTF8(ByteSink &sink) const; 1662b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 1663b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru#if U_HAVE_STD_STRING 1664b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 1665b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru /** 1666b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Convert the UnicodeString to UTF-8 and append the result 1667b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * to a standard string. 1668b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Unpaired surrogates are replaced with U+FFFD. 1669b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Calls toUTF8(). 1670b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * 167150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param result A standard string (or a compatible object) 1672b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * to which the UTF-8 version of the string is appended. 1673b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @return The string object. 167450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @stable ICU 4.2 1675b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @see toUTF8 1676b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru */ 1677b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru template<typename StringClass> 1678b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru StringClass &toUTF8String(StringClass &result) const { 1679b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru StringByteSink<StringClass> sbs(&result); 1680b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru toUTF8(sbs); 1681b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru return result; 1682b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru } 1683b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 1684b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru#endif 1685b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 1686b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru /** 1687b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Convert the UnicodeString to UTF-32. 1688b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Unpaired surrogates are replaced with U+FFFD. 1689b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Calls u_strToUTF32WithSub(). 1690b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * 1691b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param utf32 destination string buffer, can be NULL if capacity==0 1692b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param capacity the number of UChar32s available at utf32 1693b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param errorCode Standard ICU error code. Its input value must 1694b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * pass the U_SUCCESS() test, or else the function returns 1695b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * immediately. Check for U_FAILURE() on output or use with 1696b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * function chaining. (See User Guide for details.) 1697b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @return The length of the UTF-32 string. 1698b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @see fromUTF32 169950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @stable ICU 4.2 1700b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru */ 1701b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru int32_t toUTF32(UChar32 *utf32, int32_t capacity, UErrorCode &errorCode) const; 1702b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 1703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Length operations */ 1704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Return the length of the UnicodeString object. 1707b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The length is the number of UChar code units are in the UnicodeString. 1708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If you want the number of code points, please use countChar32(). 1709b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the length of the UnicodeString object 1710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see countChar32 1711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1712b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t length(void) const; 1714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Count Unicode code points in the length UChar code units of the string. 1717b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * A code point may occupy either one or two UChar code units. 1718b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Counting code points involves reading all code units. 1719b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1720b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This functions is basically the inverse of moveIndex32(). 1721b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1722b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the index of the first code unit to check 1723b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of UChar code units to check 1724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the number of code points in the specified code units 1725b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see length 1726b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1728b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t 1729b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru countChar32(int32_t start=0, int32_t length=INT32_MAX) const; 1730b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Check if the length UChar code units of the string 1733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * contain more Unicode code points than a certain number. 1734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is more efficient than counting all code points in this part of the string 1735b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and comparing that number with a threshold. 1736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function may not need to scan the string at all if the length 1737b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * falls within a certain range, and 1738b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * never needs to count more than 'number+1' code points. 1739b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Logically equivalent to (countChar32(start, length)>number). 1740b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * A Unicode code point may occupy either one or two UChar code units. 1741b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1742b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the index of the first code unit to check (0 for the entire string) 1743b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of UChar code units to check 1744b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (use INT32_MAX for the entire string; remember that start/length 1745b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * values are pinned) 1746b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param number The number of code points in the (sub)string is compared against 1747b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the 'number' parameter. 1748b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return Boolean value for whether the string contains more Unicode code points 1749b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * than 'number'. Same as (u_countChar32(s, length)>number). 1750b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see countChar32 1751b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see u_strHasMoreChar32Than 1752b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.4 1753b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1754b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBool 1755b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru hasMoreChar32Than(int32_t start, int32_t length, int32_t number) const; 1756b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1757b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Determine if this string is empty. 1759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if this string contains 0 characters, FALSE otherwise. 1760b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool isEmpty(void) const; 1763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1765b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Return the capacity of the internal buffer of the UnicodeString object. 1766b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is useful together with the getBuffer functions. 1767b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * See there for details. 1768b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1769b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the number of UChars available in the internal buffer 1770b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see getBuffer 1771b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1772b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1773b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t getCapacity(void) const; 1774b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1775b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Other operations */ 1776b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1777b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1778b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Generate a hash code for this object. 1779b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The hash code of this UnicodeString. 1780b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1781b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1782b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int32_t hashCode(void) const; 1783b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1784b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1785b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Determine if this object contains a valid string. 178650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * A bogus string has no value. It is different from an empty string, 178750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * although in both cases isEmpty() returns TRUE and length() returns 0. 178850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * setToBogus() and isBogus() can be used to indicate that no string value is available. 178950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * For a bogus string, getBuffer() and getTerminatedBuffer() return NULL, and 1790b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * length() returns 0. 1791b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1792b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if the string is valid, FALSE otherwise 1793b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see setToBogus() 1794b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1795b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1796b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool isBogus(void) const; 1797b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1798b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1799b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru //======================================== 1800b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // Write operations 1801b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru //======================================== 1802b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1803b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Assignment operations */ 1804b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1805b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1806b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Assignment operator. Replace the characters in this UnicodeString 1807b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * with the characters from <TT>srcText</TT>. 1808b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText The text containing the characters to replace 1809b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 1810b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1811b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1812b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString &operator=(const UnicodeString &srcText); 1813b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1814b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1815b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Almost the same as the assignment operator. 1816b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace the characters in this UnicodeString 1817b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * with the characters from <code>srcText</code>. 1818b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1819b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function works the same for all strings except for ones that 1820b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * are readonly aliases. 1821b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Starting with ICU 2.4, the assignment operator and the copy constructor 1822b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * allocate a new buffer and copy the buffer contents even for readonly aliases. 1823b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function implements the old, more efficient but less safe behavior 1824b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of making this string also a readonly alias to the same buffer. 1825b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The fastCopyFrom function must be used only if it is known that the lifetime of 1826b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this UnicodeString is at least as long as the lifetime of the aliased buffer 1827b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * including its contents, for example for strings from resource bundles 1828b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or aliases to string contents. 1829b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1830b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src The text containing the characters to replace. 1831b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 1832b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.4 1833b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1834b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString &fastCopyFrom(const UnicodeString &src); 1835b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1836b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1837b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Assignment operator. Replace the characters in this UnicodeString 1838b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * with the code unit <TT>ch</TT>. 1839b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ch the code unit to replace 1840b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 1841b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1842b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1843b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& operator= (UChar ch); 1844b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1845b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1846b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Assignment operator. Replace the characters in this UnicodeString 1847b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * with the code point <TT>ch</TT>. 1848b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ch the code point to replace 1849b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 1850b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1851b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1852b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& operator= (UChar32 ch); 1853b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1854b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1855b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set the text in the UnicodeString object to the characters 1856b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcText</TT> in the range 1857b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcText.length()</TT>). 1858b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcText</TT> is not modified. 1859b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the source for the new characters 1860b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcText</TT> where new characters 1861b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be obtained 1862b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 1863b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.2 1864b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1865b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& setTo(const UnicodeString& srcText, 1866b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart); 1867b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1868b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1869b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set the text in the UnicodeString object to the characters 1870b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcText</TT> in the range 1871b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>). 1872b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcText</TT> is not modified. 1873b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the source for the new characters 1874b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcText</TT> where new characters 1875b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be obtained 1876b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcText</TT> in the 1877b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * replace string. 1878b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 1879b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1880b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1881b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& setTo(const UnicodeString& srcText, 1882b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 1883b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength); 1884b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1885b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1886b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set the text in the UnicodeString object to the characters in 1887b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcText</TT>. 1888b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcText</TT> is not modified. 1889b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the source for the new characters 1890b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 1891b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1892b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1893b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& setTo(const UnicodeString& srcText); 1894b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1895b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1896b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set the characters in the UnicodeString object to the characters 1897b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcChars</TT>. <TT>srcChars</TT> is not modified. 1898b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars the source for the new characters 1899b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of Unicode characters in srcChars. 1900b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 1901b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1902b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1903b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& setTo(const UChar *srcChars, 1904b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength); 1905b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1906b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1907b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set the characters in the UnicodeString object to the code unit 1908b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcChar</TT>. 1909b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChar the code unit which becomes the UnicodeString's character 1910b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * content 1911b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 1912b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1913b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1914b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& setTo(UChar srcChar); 1915b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1916b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1917b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set the characters in the UnicodeString object to the code point 1918b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcChar</TT>. 1919b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChar the code point which becomes the UnicodeString's character 1920b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * content 1921b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 1922b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1923b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1924b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& setTo(UChar32 srcChar); 1925b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1926b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1927b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Aliasing setTo() function, analogous to the readonly-aliasing UChar* constructor. 1928b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The text will be used for the UnicodeString object, but 1929b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * it will not be released when the UnicodeString is destroyed. 1930b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This has copy-on-write semantics: 1931b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When the string is modified, then the buffer is first copied into 1932b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * newly allocated memory. 1933b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The aliased buffer is never modified. 1934b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In an assignment to another UnicodeString, the text will be aliased again, 1935b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * so that both strings then alias the same readonly-text. 1936b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1937b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param isTerminated specifies if <code>text</code> is <code>NUL</code>-terminated. 1938b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This must be true if <code>textLength==-1</code>. 1939b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The characters to alias for the UnicodeString. 1940b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param textLength The number of Unicode characters in <code>text</code> to alias. 1941b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If -1, then this constructor will determine the length 1942b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * by calling <code>u_strlen()</code>. 1943b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 1944b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1945b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1946b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString &setTo(UBool isTerminated, 1947b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *text, 1948b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t textLength); 1949b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1950b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1951b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Aliasing setTo() function, analogous to the writable-aliasing UChar* constructor. 1952b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The text will be used for the UnicodeString object, but 1953b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * it will not be released when the UnicodeString is destroyed. 1954b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This has write-through semantics: 1955b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For as long as the capacity of the buffer is sufficient, write operations 1956b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will directly affect the buffer. When more capacity is necessary, then 1957b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a new buffer will be allocated and the contents copied as with regularly 1958b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * constructed strings. 1959b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In an assignment to another UnicodeString, the buffer will be copied. 1960b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The extract(UChar *dst) function detects whether the dst pointer is the same 1961b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * as the string buffer itself and will in this case not copy the contents. 1962b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1963b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param buffer The characters to alias for the UnicodeString. 1964b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param buffLength The number of Unicode characters in <code>buffer</code> to alias. 1965b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param buffCapacity The size of <code>buffer</code> in UChars. 1966b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 1967b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 1968b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1969b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString &setTo(UChar *buffer, 1970b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t buffLength, 1971b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t buffCapacity); 1972b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1973b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1974b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Make this UnicodeString object invalid. 1975b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The string will test TRUE with isBogus(). 1976b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1977b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * A bogus string has no value. It is different from an empty string. 1978b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It can be used to indicate that no string value is available. 1979b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * getBuffer() and getTerminatedBuffer() return NULL, and 1980b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * length() returns 0. 1981b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1982b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This utility function is used throughout the UnicodeString 1983b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * implementation to indicate that a UnicodeString operation failed, 1984b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and may be used in other functions, 1985b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * especially but not exclusively when such functions do not 1986b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * take a UErrorCode for simplicity. 1987b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1988b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The following methods, and no others, will clear a string object's bogus flag: 1989b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - remove() 1990b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - remove(0, INT32_MAX) 1991b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - truncate(0) 1992b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - operator=() (assignment operator) 1993b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - setTo(...) 1994b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1995b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The simplest ways to turn a bogus string into an empty one 1996b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is to use the remove() function. 1997b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Examples for other functions that are equivalent to "set to empty string": 1998b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \code 1999b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if(s.isBogus()) { 2000b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * s.remove(); // set to an empty string (remove all), or 2001b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * s.remove(0, INT32_MAX); // set to an empty string (remove all), or 2002b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * s.truncate(0); // set to an empty string (complete truncation), or 2003b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * s=UnicodeString(); // assign an empty string, or 2004b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * s.setTo((UChar32)-1); // set to a pseudo code point that is out of range, or 2005b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * static const UChar nul=0; 2006b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * s.setTo(&nul, 0); // set to an empty C Unicode string 2007b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * } 2008b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \endcode 2009b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2010b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see isBogus() 2011b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2012b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2013b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru void setToBogus(); 2014b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2015b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2016b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set the character at the specified offset to the specified character. 2017b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param offset A valid offset into the text of the character to set 2018b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ch The new character 2019b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A reference to this 2020b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2021b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2022b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& setCharAt(int32_t offset, 2023b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar ch); 2024b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2025b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2026b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Append operations */ 2027b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2028b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2029b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Append operator. Append the code unit <TT>ch</TT> to the UnicodeString 2030b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * object. 2031b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ch the code unit to be appended 2032b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2033b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2034b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2035b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& operator+= (UChar ch); 2036b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2037b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2038b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Append operator. Append the code point <TT>ch</TT> to the UnicodeString 2039b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * object. 2040b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ch the code point to be appended 2041b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2042b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2043b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2044b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& operator+= (UChar32 ch); 2045b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2046b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2047b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Append operator. Append the characters in <TT>srcText</TT> to the 2048b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * UnicodeString object. <TT>srcText</TT> is not modified. 2049b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the source for the new characters 2050b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2051b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2052b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2053b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& operator+= (const UnicodeString& srcText); 2054b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2055b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2056b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Append the characters 2057b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcText</TT> in the range 2058b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) to the 2059b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UnicodeString object at offset <TT>start</TT>. <TT>srcText</TT> 2060b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is not modified. 2061b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the source for the new characters 2062b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcText</TT> where new characters 2063b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be obtained 2064b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcText</TT> in 2065b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the append string 2066b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2067b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2068b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2069b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& append(const UnicodeString& srcText, 2070b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 2071b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength); 2072b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2073b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2074b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * Append the characters in <TT>srcText</TT> to the UnicodeString object. 2075b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * <TT>srcText</TT> is not modified. 2076b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the source for the new characters 2077b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2078b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2079b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2080b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& append(const UnicodeString& srcText); 2081b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2082b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2083b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Append the characters in <TT>srcChars</TT> in the range 2084b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) to the UnicodeString 2085b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * object at offset 2086b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>start</TT>. <TT>srcChars</TT> is not modified. 2087b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars the source for the new characters 2088b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcChars</TT> where new characters 2089b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be obtained 2090b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> in 2091b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * the append string; can be -1 if <TT>srcChars</TT> is NUL-terminated 2092b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2093b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2094b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2095b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& append(const UChar *srcChars, 2096b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 2097b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength); 2098b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2099b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Append the characters in <TT>srcChars</TT> to the UnicodeString object 2101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * at offset <TT>start</TT>. <TT>srcChars</TT> is not modified. 2102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars the source for the new characters 2103b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * @param srcLength the number of Unicode characters in <TT>srcChars</TT>; 2104b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * can be -1 if <TT>srcChars</TT> is NUL-terminated 2105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& append(const UChar *srcChars, 2109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength); 2110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Append the code unit <TT>srcChar</TT> to the UnicodeString object. 2113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChar the code unit to append 2114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& append(UChar srcChar); 2118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Append the code point <TT>srcChar</TT> to the UnicodeString object. 2121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChar the code point to append 2122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2125103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UnicodeString& append(UChar32 srcChar); 2126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Insert operations */ 2129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Insert the characters in <TT>srcText</TT> in the range 2132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) into the UnicodeString 2133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * object at offset <TT>start</TT>. <TT>srcText</TT> is not modified. 2134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset where the insertion begins 2135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the source for the new characters 2136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcText</TT> where new characters 2137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be obtained 2138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcText</TT> in 2139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the insert string 2140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& insert(int32_t start, 2144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 2145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 2146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength); 2147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Insert the characters in <TT>srcText</TT> into the UnicodeString object 2150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * at offset <TT>start</TT>. <TT>srcText</TT> is not modified. 2151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset where the insertion begins 2152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the source for the new characters 2153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& insert(int32_t start, 2157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText); 2158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Insert the characters in <TT>srcChars</TT> in the range 2161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) into the UnicodeString 2162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * object at offset <TT>start</TT>. <TT>srcChars</TT> is not modified. 2163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the insertion begins 2164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars the source for the new characters 2165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcChars</TT> where new characters 2166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be obtained 2167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> 2168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the insert string 2169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& insert(int32_t start, 2173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 2174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 2175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength); 2176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Insert the characters in <TT>srcChars</TT> into the UnicodeString object 2179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * at offset <TT>start</TT>. <TT>srcChars</TT> is not modified. 2180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset where the insertion begins 2181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars the source for the new characters 2182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of Unicode characters in srcChars. 2183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& insert(int32_t start, 2187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 2188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength); 2189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Insert the code unit <TT>srcChar</TT> into the UnicodeString object at 2192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * offset <TT>start</TT>. 2193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the insertion occurs 2194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChar the code unit to insert 2195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& insert(int32_t start, 2199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar srcChar); 2200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Insert the code point <TT>srcChar</TT> into the UnicodeString object at 2203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * offset <TT>start</TT>. 2204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the insertion occurs 2205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChar the code point to insert 2206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& insert(int32_t start, 2210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar32 srcChar); 2211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Replace operations */ 2214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace the characters in the range 2217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) with the characters in 2218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcText</TT> in the range 2219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>). 2220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcText</TT> is not modified. 2221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the replace operation begins 2222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters to replace. The character at 2223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>start + length</TT> is not modified. 2224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the source for the new characters 2225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcText</TT> where new characters 2226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be obtained 2227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcText</TT> in 2228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the replace string 2229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& replace(int32_t start, 2233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 2234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 2235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 2236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength); 2237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace the characters in the range 2240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) 2241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * with the characters in <TT>srcText</TT>. <TT>srcText</TT> is 2242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * not modified. 2243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the replace operation begins 2244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters to replace. The character at 2245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>start + length</TT> is not modified. 2246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the source for the new characters 2247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& replace(int32_t start, 2251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 2252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText); 2253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace the characters in the range 2256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) with the characters in 2257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcChars</TT> in the range 2258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>). <TT>srcChars</TT> 2259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is not modified. 2260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the replace operation begins 2261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters to replace. The character at 2262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>start + length</TT> is not modified. 2263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars the source for the new characters 2264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcChars</TT> where new characters 2265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be obtained 2266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of characters in <TT>srcChars</TT> 2267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the replace string 2268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& replace(int32_t start, 2272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 2273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 2274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 2275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength); 2276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace the characters in the range 2279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) with the characters in 2280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcChars</TT>. <TT>srcChars</TT> is not modified. 2281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the replace operation begins 2282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length number of characters to replace. The character at 2283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>start + length</TT> is not modified. 2284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChars the source for the new characters 2285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength the number of Unicode characters in srcChars 2286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& replace(int32_t start, 2290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 2291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 2292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength); 2293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace the characters in the range 2296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) with the code unit 2297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcChar</TT>. 2298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the replace operation begins 2299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters to replace. The character at 2300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>start + length</TT> is not modified. 2301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChar the new code unit 2302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& replace(int32_t start, 2306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 2307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar srcChar); 2308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace the characters in the range 2311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) with the code point 2312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>srcChar</TT>. 2313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the replace operation begins 2314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters to replace. The character at 2315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <TT>start + length</TT> is not modified. 2316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcChar the new code point 2317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2320103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UnicodeString& replace(int32_t start, int32_t length, UChar32 srcChar); 2321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace the characters in the range [<TT>start</TT>, <TT>limit</TT>) 2324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * with the characters in <TT>srcText</TT>. <TT>srcText</TT> is not modified. 2325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the replace operation begins 2326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limit the offset immediately following the replace range 2327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the source for the new characters 2328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& replaceBetween(int32_t start, 2332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 2333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText); 2334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace the characters in the range [<TT>start</TT>, <TT>limit</TT>) 2337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * with the characters in <TT>srcText</TT> in the range 2338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>srcStart</TT>, <TT>srcLimit</TT>). <TT>srcText</TT> is not modified. 2339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset at which the replace operation begins 2340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limit the offset immediately following the replace range 2341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcText the source for the new characters 2342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart the offset into <TT>srcChars</TT> where new characters 2343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be obtained 2344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLimit the offset immediately following the range to copy 2345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in <TT>srcText</TT> 2346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& replaceBetween(int32_t start, 2350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 2351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 2352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 2353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLimit); 2354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace a substring of this object with the given text. 2357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the beginning index, inclusive; <code>0 <= start 2358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <= limit</code>. 2359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limit the ending index, exclusive; <code>start <= limit 2360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <= length()</code>. 2361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text the text to replace characters <code>start</code> 2362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to <code>limit - 1</code> 2363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual void handleReplaceBetween(int32_t start, 2366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 2367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& text); 2368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replaceable API 2371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if it has MetaData 2372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.4 2373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual UBool hasMetaData() const; 2375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy a substring of this object, retaining attribute (out-of-band) 2378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * information. This method is used to duplicate or reorder substrings. 2379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The destination index must not overlap the source range. 2380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the beginning index, inclusive; <code>0 <= start <= 2382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * limit</code>. 2383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limit the ending index, exclusive; <code>start <= limit <= 2384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * length()</code>. 2385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest the destination index. The characters from 2386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>start..limit-1</code> will be copied to <code>dest</code>. 2387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Implementations of this method may assume that <code>dest <= start || 2388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * dest >= limit</code>. 2389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual void copy(int32_t start, int32_t limit, int32_t dest); 2392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Search and replace operations */ 2394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace all occurrences of characters in oldText with the characters 2397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in newText 2398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param oldText the text containing the search text 2399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param newText the text containing the replacement text 2400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& findAndReplace(const UnicodeString& oldText, 2404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& newText); 2405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace all occurrences of characters in oldText with characters 2408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in newText 2409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the range [<TT>start</TT>, <TT>start + length</TT>). 2410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the start of the range in which replace will performed 2411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the length of the range in which replace will be performed 2412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param oldText the text containing the search text 2413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param newText the text containing the replacement text 2414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& findAndReplace(int32_t start, 2418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 2419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& oldText, 2420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& newText); 2421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace all occurrences of characters in oldText in the range 2424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>oldStart</TT>, <TT>oldStart + oldLength</TT>) with the characters 2425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in newText in the range 2426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>newStart</TT>, <TT>newStart + newLength</TT>) 2427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the range [<TT>start</TT>, <TT>start + length</TT>). 2428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the start of the range in which replace will performed 2429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the length of the range in which replace will be performed 2430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param oldText the text containing the search text 2431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param oldStart the start of the search range in <TT>oldText</TT> 2432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param oldLength the length of the search range in <TT>oldText</TT> 2433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param newText the text containing the replacement text 2434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param newStart the start of the replacement range in <TT>newText</TT> 2435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param newLength the length of the replacement range in <TT>newText</TT> 2436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& findAndReplace(int32_t start, 2440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 2441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& oldText, 2442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t oldStart, 2443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t oldLength, 2444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& newText, 2445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t newStart, 2446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t newLength); 2447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Remove operations */ 2450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Remove all characters from the UnicodeString object. 2453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& remove(void); 2457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Remove the characters in the range 2460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>start + length</TT>) from the UnicodeString object. 2461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset of the first character to remove 2462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters to remove 2463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& remove(int32_t start, 2467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length = (int32_t)INT32_MAX); 2468b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Remove the characters in the range 2471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * [<TT>start</TT>, <TT>limit</TT>) from the UnicodeString object. 2472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the offset of the first character to remove 2473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param limit the offset immediately following the range to remove 2474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& removeBetween(int32_t start, 2478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit = (int32_t)INT32_MAX); 2479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 248050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho /** 248150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Retain only the characters in the range 248250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * [<code>start</code>, <code>limit</code>) from the UnicodeString object. 248350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Removes characters before <code>start</code> and at and after <code>limit</code>. 248450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param start the offset of the first character to retain 248550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param limit the offset immediately following the range to retain 248650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return a reference to this 248727f654740f2a26ad62a5c155af9199af9e69b889claireho * @stable ICU 4.4 248850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 248950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho inline UnicodeString &retainBetween(int32_t start, int32_t limit = INT32_MAX); 2490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Length operations */ 2492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Pad the start of this UnicodeString with the character <TT>padChar</TT>. 2495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the length of this UnicodeString is less than targetLength, 2496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * length() - targetLength copies of padChar will be added to the 2497b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * beginning of this UnicodeString. 2498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param targetLength the desired length of the string 2499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param padChar the character to use for padding. Defaults to 2500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * space (U+0020) 2501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if the text was padded, FALSE otherwise. 2502b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBool padLeading(int32_t targetLength, 2505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar padChar = 0x0020); 2506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2508b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Pad the end of this UnicodeString with the character <TT>padChar</TT>. 2509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the length of this UnicodeString is less than targetLength, 2510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * length() - targetLength copies of padChar will be added to the 2511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * end of this UnicodeString. 2512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param targetLength the desired length of the string 2513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param padChar the character to use for padding. Defaults to 2514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * space (U+0020) 2515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if the text was padded, FALSE otherwise. 2516b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2518b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBool padTrailing(int32_t targetLength, 2519b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar padChar = 0x0020); 2520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Truncate this UnicodeString to the <TT>targetLength</TT>. 2523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param targetLength the desired length of this UnicodeString. 2524b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if the text was truncated, FALSE otherwise 2525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2526b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UBool truncate(int32_t targetLength); 2528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Trims leading and trailing whitespace from this UnicodeString. 2531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2532b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2534b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& trim(void); 2535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Miscellaneous operations */ 2538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Reverse this UnicodeString in place. 2541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& reverse(void); 2545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Reverse the range [<TT>start</TT>, <TT>start + length</TT>) in 2548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this UnicodeString. 2549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param start the start of the range to reverse 2550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length the number of characters to to reverse 2551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a reference to this 2552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UnicodeString& reverse(int32_t start, 2555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length); 2556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Convert the characters in this to UPPER CASE following the conventions of 2559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the default locale. 2560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A reference to this. 2561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& toUpper(void); 2564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Convert the characters in this to UPPER CASE following the conventions of 2567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a specific locale. 2568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param locale The locale containing the conventions to use. 2569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A reference to this. 2570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& toUpper(const Locale& locale); 2573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Convert the characters in this to lower case following the conventions of 2576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the default locale. 2577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A reference to this. 2578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& toLower(void); 2581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2583b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Convert the characters in this to lower case following the conventions of 2584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a specific locale. 2585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param locale The locale containing the conventions to use. 2586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A reference to this. 2587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& toLower(const Locale& locale); 2590b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_BREAK_ITERATION 2592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Titlecase this string, convenience function using the default locale. 2595b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Casing is locale-dependent and context-sensitive. 2597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Titlecasing uses a break iterator to find the first characters of words 2598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that are to be titlecased. It titlecases those characters and lowercases 2599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * all others. 2600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2601b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The titlecase break iterator can be provided to customize for arbitrary 2602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * styles, using rules and dictionaries beyond the standard iterators. 2603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It may be more efficient to always provide an iterator to avoid 2604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * opening and closing one for each string. 2605b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The standard titlecase iterator for the root locale implements the 2606b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * algorithm of Unicode TR 21. 2607b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function uses only the setText(), first() and next() methods of the 2609b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * provided break iterator. 2610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param titleIter A break iterator to find the first characters of words 2612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that are to be titlecased. 2613b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If none is provided (0), then a standard titlecase 2614b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * break iterator is opened. 2615b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Otherwise the provided iterator is set to the string's text. 2616b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A reference to this. 2617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.1 2618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString &toTitle(BreakIterator *titleIter); 2620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2622b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Titlecase this string. 2623b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2624b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Casing is locale-dependent and context-sensitive. 2625b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Titlecasing uses a break iterator to find the first characters of words 2626b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that are to be titlecased. It titlecases those characters and lowercases 2627b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * all others. 2628b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2629b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The titlecase break iterator can be provided to customize for arbitrary 2630b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * styles, using rules and dictionaries beyond the standard iterators. 2631b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It may be more efficient to always provide an iterator to avoid 2632b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * opening and closing one for each string. 2633b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The standard titlecase iterator for the root locale implements the 2634b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * algorithm of Unicode TR 21. 2635b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2636b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function uses only the setText(), first() and next() methods of the 2637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * provided break iterator. 2638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param titleIter A break iterator to find the first characters of words 2640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that are to be titlecased. 2641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If none is provided (0), then a standard titlecase 2642b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * break iterator is opened. 2643b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Otherwise the provided iterator is set to the string's text. 2644b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param locale The locale to consider. 2645b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A reference to this. 2646b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.1 2647b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2648b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString &toTitle(BreakIterator *titleIter, const Locale &locale); 2649b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2650b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2651b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Titlecase this string, with options. 2652b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2653b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Casing is locale-dependent and context-sensitive. 2654b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Titlecasing uses a break iterator to find the first characters of words 2655b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that are to be titlecased. It titlecases those characters and lowercases 2656b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * all others. (This can be modified with options.) 2657b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2658b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The titlecase break iterator can be provided to customize for arbitrary 2659b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * styles, using rules and dictionaries beyond the standard iterators. 2660b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It may be more efficient to always provide an iterator to avoid 2661b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * opening and closing one for each string. 2662b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The standard titlecase iterator for the root locale implements the 2663b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * algorithm of Unicode TR 21. 2664b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2665b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function uses only the setText(), first() and next() methods of the 2666b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * provided break iterator. 2667b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2668b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param titleIter A break iterator to find the first characters of words 2669b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that are to be titlecased. 2670b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If none is provided (0), then a standard titlecase 2671b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * break iterator is opened. 2672b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Otherwise the provided iterator is set to the string's text. 2673b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param locale The locale to consider. 2674b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options Options bit set, see ucasemap_open(). 2675b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A reference to this. 2676b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see U_TITLECASE_NO_LOWERCASE 2677b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see U_TITLECASE_NO_BREAK_ADJUSTMENT 2678b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see ucasemap_open 2679b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @stable ICU 3.8 2680b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2681b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString &toTitle(BreakIterator *titleIter, const Locale &locale, uint32_t options); 2682b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 2684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Case-fold the characters in this string. 2687b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Case-folding is locale-independent and not context-sensitive, 2688b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * but there is an option for whether to include or exclude mappings for dotted I 2689b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and dotless i that are marked with 'I' in CaseFolding.txt. 2690b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The result may be longer or shorter than the original. 2691b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2692b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options Either U_FOLD_CASE_DEFAULT or U_FOLD_CASE_EXCLUDE_SPECIAL_I 2693b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return A reference to this. 2694b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2695b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2696b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString &foldCase(uint32_t options=0 /*U_FOLD_CASE_DEFAULT*/); 2697b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2698b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru //======================================== 2699b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // Access to the internal buffer 2700b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru //======================================== 2701b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2702b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Get a read/write pointer to the internal buffer. 2704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The buffer is guaranteed to be large enough for at least minCapacity UChars, 2705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * writable, and is still owned by the UnicodeString object. 2706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Calls to getBuffer(minCapacity) must not be nested, and 2707b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * must be matched with calls to releaseBuffer(newLength). 2708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the string buffer was read-only or shared, 2709b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * then it will be reallocated and copied. 2710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * An attempted nested call will return 0, and will not further modify the 2712b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * state of the UnicodeString object. 2713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It also returns 0 if the string is bogus. 2714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The actual capacity of the string buffer may be larger than minCapacity. 2716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * getCapacity() returns the actual capacity. 2717b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For many operations, the full capacity should be used to avoid reallocations. 2718b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2719b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * While the buffer is "open" between getBuffer(minCapacity) 2720b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and releaseBuffer(newLength), the following applies: 2721b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - The string length is set to 0. 2722b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - Any read API call on the UnicodeString object will behave like on a 0-length string. 2723b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - Any write API call on the UnicodeString object is disallowed and will have no effect. 2724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - You can read from and write to the returned buffer. 2725b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - The previous string contents will still be in the buffer; 2726b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if you want to use it, then you need to call length() before getBuffer(minCapacity). 2727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the length() was greater than minCapacity, then any contents after minCapacity 2728b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * may be lost. 2729b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The buffer contents is not NUL-terminated by getBuffer(). 2730b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If length()<getCapacity() then you can terminate it by writing a NUL 2731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * at index length(). 2732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - You must call releaseBuffer(newLength) before and in order to 2733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * return to normal UnicodeString operation. 2734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2735b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param minCapacity the minimum number of UChars that are to be available 2736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in the buffer, starting at the returned pointer; 2737b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * default to the current string capacity if minCapacity==-1 2738b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a writable pointer to the internal string buffer, 2739b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or 0 if an error occurs (nested calls, out of memory) 2740b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2741b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see releaseBuffer 2742b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see getTerminatedBuffer() 2743b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2744b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2745b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar *getBuffer(int32_t minCapacity); 2746b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2747b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2748b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Release a read/write buffer on a UnicodeString object with an 2749b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * "open" getBuffer(minCapacity). 2750b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function must be called in a matched pair with getBuffer(minCapacity). 2751b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * releaseBuffer(newLength) must be called if and only if a getBuffer(minCapacity) is "open". 2752b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2753b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It will set the string length to newLength, at most to the current capacity. 2754b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If newLength==-1 then it will set the length according to the 2755b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * first NUL in the buffer, or to the capacity if there is no NUL. 2756b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2757b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * After calling releaseBuffer(newLength) the UnicodeString is back to normal operation. 2758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param newLength the new length of the UnicodeString object; 2760b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * defaults to the current capacity if newLength is greater than that; 2761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if newLength==-1, it defaults to u_strlen(buffer) but not more than 2762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the current capacity of the string 2763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see getBuffer(int32_t minCapacity) 2765b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2766b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2767b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru void releaseBuffer(int32_t newLength=-1); 2768b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2769b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2770b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Get a read-only pointer to the internal buffer. 2771b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This can be called at any time on a valid UnicodeString. 2772b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2773b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It returns 0 if the string is bogus, or 2774b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * during an "open" getBuffer(minCapacity). 2775b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2776b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It can be called as many times as desired. 2777b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The pointer that it returns will remain valid until the UnicodeString object is modified, 2778b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * at which time the pointer is semantically invalidated and must not be used any more. 2779b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2780b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The capacity of the buffer can be determined with getCapacity(). 2781b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The part after length() may or may not be initialized and valid, 2782b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * depending on the history of the UnicodeString object. 2783b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2784b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The buffer contents is (probably) not NUL-terminated. 2785b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * You can check if it is with 2786b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <code>(s.length()<s.getCapacity() && buffer[s.length()]==0)</code>. 2787b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (See getTerminatedBuffer().) 2788b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2789b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The buffer may reside in read-only memory. Its contents must not 2790b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * be modified. 2791b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2792b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a read-only pointer to the internal string buffer, 2793b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or 0 if the string is empty or bogus 2794b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2795b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see getBuffer(int32_t minCapacity) 2796b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see getTerminatedBuffer() 2797b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2798b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2799b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline const UChar *getBuffer() const; 2800b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2801b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2802b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Get a read-only pointer to the internal buffer, 2803b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * making sure that it is NUL-terminated. 2804b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This can be called at any time on a valid UnicodeString. 2805b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2806b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It returns 0 if the string is bogus, or 2807b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * during an "open" getBuffer(minCapacity), or if the buffer cannot 2808b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * be NUL-terminated (because memory allocation failed). 2809b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2810b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It can be called as many times as desired. 2811b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The pointer that it returns will remain valid until the UnicodeString object is modified, 2812b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * at which time the pointer is semantically invalidated and must not be used any more. 2813b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2814b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The capacity of the buffer can be determined with getCapacity(). 2815b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The part after length()+1 may or may not be initialized and valid, 2816b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * depending on the history of the UnicodeString object. 2817b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2818b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The buffer contents is guaranteed to be NUL-terminated. 2819b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * getTerminatedBuffer() may reallocate the buffer if a terminating NUL 2820b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is written. 2821b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For this reason, this function is not const, unlike getBuffer(). 2822b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Note that a UnicodeString may also contain NUL characters as part of its contents. 2823b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2824b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The buffer may reside in read-only memory. Its contents must not 2825b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * be modified. 2826b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2827b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a read-only pointer to the internal string buffer, 2828b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or 0 if the string is empty or bogus 2829b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2830b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see getBuffer(int32_t minCapacity) 2831b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see getBuffer() 2832b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.2 2833b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2834b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline const UChar *getTerminatedBuffer(); 2835b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2836b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru //======================================== 2837b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // Constructors 2838b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru //======================================== 2839b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2840b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** Construct an empty UnicodeString. 2841b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2842b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2843b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString(); 2844b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2845b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2846b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Construct a UnicodeString with capacity to hold <TT>capacity</TT> UChars 2847b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param capacity the number of UChars this UnicodeString should hold 2848b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * before a resize is necessary; if count is greater than 0 and count 2849b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * code points c take up more space than capacity, then capacity is adjusted 2850b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * accordingly. 2851b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c is used to initially fill the string 2852b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param count specifies how many code points c are to be written in the 2853b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * string 2854b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2855b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2856b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString(int32_t capacity, UChar32 c, int32_t count); 2857b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2858b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2859b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Single UChar (code unit) constructor. 2860103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * 2861103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * It is recommended to mark this constructor "explicit" by 2862103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <code>-DUNISTR_FROM_CHAR_EXPLICIT=explicit</code> 2863103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * on the compiler command line or similar. 2864b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ch the character to place in the UnicodeString 2865b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2866b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2867103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UNISTR_FROM_CHAR_EXPLICIT UnicodeString(UChar ch); 2868b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2869b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2870b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Single UChar32 (code point) constructor. 2871103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * 2872103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * It is recommended to mark this constructor "explicit" by 2873103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <code>-DUNISTR_FROM_CHAR_EXPLICIT=explicit</code> 2874103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * on the compiler command line or similar. 2875b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ch the character to place in the UnicodeString 2876b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2877b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2878103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UNISTR_FROM_CHAR_EXPLICIT UnicodeString(UChar32 ch); 2879b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2880b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2881b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UChar* constructor. 2882103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * 2883103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * It is recommended to mark this constructor "explicit" by 2884103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <code>-DUNISTR_FROM_STRING_EXPLICIT=explicit</code> 2885103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * on the compiler command line or similar. 2886b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The characters to place in the UnicodeString. <TT>text</TT> 2887b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * must be NULL (U+0000) terminated. 2888b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2889b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2890103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UNISTR_FROM_STRING_EXPLICIT UnicodeString(const UChar *text); 2891b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2892b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2893b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UChar* constructor. 2894b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The characters to place in the UnicodeString. 2895b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param textLength The number of Unicode characters in <TT>text</TT> 2896b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to copy. 2897b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2898b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2899b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString(const UChar *text, 2900b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t textLength); 2901b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2902b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2903b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Readonly-aliasing UChar* constructor. 2904b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The text will be used for the UnicodeString object, but 2905b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * it will not be released when the UnicodeString is destroyed. 2906b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This has copy-on-write semantics: 2907b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When the string is modified, then the buffer is first copied into 2908b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * newly allocated memory. 2909b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The aliased buffer is never modified. 2910b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In an assignment to another UnicodeString, the text will be aliased again, 2911b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * so that both strings then alias the same readonly-text. 2912b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2913b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param isTerminated specifies if <code>text</code> is <code>NUL</code>-terminated. 2914b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This must be true if <code>textLength==-1</code>. 2915b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param text The characters to alias for the UnicodeString. 2916b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param textLength The number of Unicode characters in <code>text</code> to alias. 2917b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If -1, then this constructor will determine the length 2918b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * by calling <code>u_strlen()</code>. 2919b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2920b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2921b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString(UBool isTerminated, 2922b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *text, 2923b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t textLength); 2924b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2925b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2926b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Writable-aliasing UChar* constructor. 2927b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The text will be used for the UnicodeString object, but 2928b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * it will not be released when the UnicodeString is destroyed. 2929b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This has write-through semantics: 2930b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For as long as the capacity of the buffer is sufficient, write operations 2931b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will directly affect the buffer. When more capacity is necessary, then 2932b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a new buffer will be allocated and the contents copied as with regularly 2933b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * constructed strings. 2934b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In an assignment to another UnicodeString, the buffer will be copied. 2935b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The extract(UChar *dst) function detects whether the dst pointer is the same 2936b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * as the string buffer itself and will in this case not copy the contents. 2937b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2938b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param buffer The characters to alias for the UnicodeString. 2939b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param buffLength The number of Unicode characters in <code>buffer</code> to alias. 2940b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param buffCapacity The size of <code>buffer</code> in UChars. 2941b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2942b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2943b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString(UChar *buffer, int32_t buffLength, int32_t buffCapacity); 2944b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2945b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru#if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION 2946b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 2947b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru /** 2948b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * char* constructor. 2949103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * Uses the default converter (and thus depends on the ICU conversion code) 2950103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * unless U_CHARSET_IS_UTF8 is set to 1. 2951103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * 2952103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * For ASCII (really "invariant character") strings it is more efficient to use 2953103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * the constructor that takes a US_INV (for its enum EInvariant). 2954103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * For ASCII (invariant-character) string literals, see UNICODE_STRING and 2955103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * UNICODE_STRING_SIMPLE. 2956103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * 2957103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * It is recommended to mark this constructor "explicit" by 2958103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <code>-DUNISTR_FROM_STRING_EXPLICIT=explicit</code> 2959103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * on the compiler command line or similar. 2960b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param codepageData an array of bytes, null-terminated, 2961b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * in the platform's default codepage. 2962b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @stable ICU 2.0 2963103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @see UNICODE_STRING 2964103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @see UNICODE_STRING_SIMPLE 2965b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru */ 2966103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UNISTR_FROM_STRING_EXPLICIT UnicodeString(const char *codepageData); 2967b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 2968b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru /** 2969b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * char* constructor. 2970103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * Uses the default converter (and thus depends on the ICU conversion code) 2971103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * unless U_CHARSET_IS_UTF8 is set to 1. 2972b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param codepageData an array of bytes in the platform's default codepage. 2973b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param dataLength The number of bytes in <TT>codepageData</TT>. 2974b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @stable ICU 2.0 2975b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru */ 2976b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru UnicodeString(const char *codepageData, int32_t dataLength); 2977b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 2978b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru#endif 2979b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 2980b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_CONVERSION 2981b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2982b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 2983b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * char* constructor. 2984b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param codepageData an array of bytes, null-terminated 2985b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param codepage the encoding of <TT>codepageData</TT>. The special 2986b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * value 0 for <TT>codepage</TT> indicates that the text is in the 2987b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * platform's default codepage. 2988b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2989b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If <code>codepage</code> is an empty string (<code>""</code>), 2990b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * then a simple conversion is performed on the codepage-invariant 2991b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * subset ("invariant characters") of the platform encoding. See utypes.h. 2992b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Recommendation: For invariant-character strings use the constructor 2993b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UnicodeString(const char *src, int32_t length, enum EInvariant inv) 2994b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * because it avoids object code dependencies of UnicodeString on 2995b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the conversion code. 2996b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2997b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 2998b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 2999b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru UnicodeString(const char *codepageData, const char *codepage); 3000b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3001b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3002b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * char* constructor. 3003b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param codepageData an array of bytes. 3004b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dataLength The number of bytes in <TT>codepageData</TT>. 3005b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param codepage the encoding of <TT>codepageData</TT>. The special 3006b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * value 0 for <TT>codepage</TT> indicates that the text is in the 3007b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * platform's default codepage. 3008b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If <code>codepage</code> is an empty string (<code>""</code>), 3009b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * then a simple conversion is performed on the codepage-invariant 3010b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * subset ("invariant characters") of the platform encoding. See utypes.h. 3011b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Recommendation: For invariant-character strings use the constructor 3012b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UnicodeString(const char *src, int32_t length, enum EInvariant inv) 3013b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * because it avoids object code dependencies of UnicodeString on 3014b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the conversion code. 3015b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3016b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 3017b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3018b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru UnicodeString(const char *codepageData, int32_t dataLength, const char *codepage); 3019b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3020b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3021b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * char * / UConverter constructor. 3022b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This constructor uses an existing UConverter object to 3023b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * convert the codepage string to Unicode and construct a UnicodeString 3024b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * from that. 3025b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3026b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The converter is reset at first. 3027b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the error code indicates a failure before this constructor is called, 3028b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or if an error occurs during conversion or construction, 3029b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * then the string will be bogus. 3030b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3031b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function avoids the overhead of opening and closing a converter if 3032b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * multiple strings are constructed. 3033b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3034b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src input codepage string 3035b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength length of the input string, can be -1 for NUL-terminated strings 3036b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param cnv converter object (ucnv_resetToUnicode() will be called), 3037b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * can be NULL for the default converter 3038b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param errorCode normal ICU error code 3039b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 3040b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3041b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString( 3042b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const char *src, int32_t srcLength, 3043b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UConverter *cnv, 3044b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode &errorCode); 3045b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3046b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 3047b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3048b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3049b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Constructs a Unicode string from an invariant-character char * string. 3050b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * About invariant characters see utypes.h. 3051b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This constructor has no runtime dependency on conversion code and is 3052b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * therefore recommended over ones taking a charset name string 3053b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (where the empty string "" indicates invariant-character conversion). 3054b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3055b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Use the macro US_INV as the third, signature-distinguishing parameter. 3056b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3057b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For example: 3058b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \code 3059b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * void fn(const char *s) { 3060b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UnicodeString ustr(s, -1, US_INV); 3061b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * // use ustr ... 3062b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * } 3063b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \endcode 3064b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3065b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src String using only invariant characters. 3066b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length Length of src, or -1 if NUL-terminated. 3067b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param inv Signature-distinguishing paramater, use US_INV. 3068b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3069b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see US_INV 3070b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.2 3071b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3072b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString(const char *src, int32_t length, enum EInvariant inv); 3073b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3074b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3075b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3076b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy constructor. 3077b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param that The UnicodeString object to copy. 3078b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 3079b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3080b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString(const UnicodeString& that); 3081b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3082b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3083b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 'Substring' constructor from tail of source string. 3084b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src The UnicodeString object to copy. 3085b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart The offset into <tt>src</tt> at which to start copying. 3086b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.2 3087b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3088b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString(const UnicodeString& src, int32_t srcStart); 3089b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3090b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3091b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 'Substring' constructor from subrange of source string. 3092b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src The UnicodeString object to copy. 3093b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcStart The offset into <tt>src</tt> at which to start copying. 3094b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength The number of characters from <tt>src</tt> to copy. 3095b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.2 3096b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3097b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString(const UnicodeString& src, int32_t srcStart, int32_t srcLength); 3098b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3099b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Clone this object, an instance of a subclass of Replaceable. 3101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Clones can be used concurrently in multiple threads. 3102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If a subclass does not implement clone(), or if an error occurs, 3103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * then NULL is returned. 3104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The clone functions in all subclasses return a pointer to a Replaceable 3105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * because some compilers do not support covariant (same-as-this) 3106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * return types; cast to the appropriate subclass if necessary. 3107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The caller must delete the clone. 3108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a clone of this object 3110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see Replaceable::clone 3112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see getDynamicClassID 3113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.6 3114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual Replaceable *clone() const; 3116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** Destructor. 3118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 3119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual ~UnicodeString(); 3121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3122b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru /** 3123b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Create a UnicodeString from a UTF-8 string. 3124b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Illegal input is replaced with U+FFFD. Otherwise, errors result in a bogus string. 3125b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Calls u_strFromUTF8WithSub(). 3126b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * 3127b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param utf8 UTF-8 input string. 3128b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Note that a StringPiece can be implicitly constructed 3129b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * from a std::string or a NUL-terminated const char * string. 3130b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @return A UnicodeString with equivalent UTF-16 contents. 3131b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @see toUTF8 3132b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @see toUTF8String 313350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @stable ICU 4.2 3134b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru */ 3135b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru static UnicodeString fromUTF8(const StringPiece &utf8); 3136b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 3137b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru /** 3138b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Create a UnicodeString from a UTF-32 string. 3139b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Illegal input is replaced with U+FFFD. Otherwise, errors result in a bogus string. 3140b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * Calls u_strFromUTF32WithSub(). 3141b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * 3142b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param utf32 UTF-32 input string. Must not be NULL. 3143b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @param length Length of the input string, or -1 if NUL-terminated. 3144b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @return A UnicodeString with equivalent UTF-16 contents. 3145b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @see toUTF32 314650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @stable ICU 4.2 3147b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru */ 3148b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru static UnicodeString fromUTF32(const UChar32 *utf32, int32_t length); 3149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Miscellaneous operations */ 3151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Unescape a string of characters and return a string containing 3154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the result. The following escape sequences are recognized: 3155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \\uhhhh 4 hex digits; h in [0-9A-Fa-f] 3157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \\Uhhhhhhhh 8 hex digits 3158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \\xhh 1-2 hex digits 3159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \\ooo 1-3 octal digits; o in [0-7] 3160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \\cX control-X; X is masked with 0x1F 3161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * as well as the standard ANSI C escapes: 3163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \\a => U+0007, \\b => U+0008, \\t => U+0009, \\n => U+000A, 3165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \\v => U+000B, \\f => U+000C, \\r => U+000D, \\e => U+001B, 316650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * \\" => U+0022, \\' => U+0027, \\? => U+003F, \\\\ => U+005C 3167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Anything else following a backslash is generically escaped. For 3169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * example, "[a\\-z]" returns "[a-z]". 3170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If an escape sequence is ill-formed, this method returns an empty 3172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * string. An example of an ill-formed sequence is "\\u" followed by 3173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * fewer than 4 hex digits. 3174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is similar to u_unescape() but not identical to it. 3176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The latter takes a source char*, so it does escape recognition 3177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and also invariant conversion. 3178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return a string with backslash escapes interpreted, or an 3180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * empty string on error. 3181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UnicodeString#unescapeAt() 3182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see u_unescape() 3183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see u_unescapeAt() 3184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 3185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString unescape() const; 3187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Unescape a single escape sequence and return the represented 3190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * character. See unescape() for a listing of the recognized escape 3191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * sequences. The character at offset-1 is assumed (without 3192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * checking) to be a backslash. If the escape sequence is 3193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * ill-formed, or the offset is out of range, (UChar32)0xFFFFFFFF is 3194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * returned. 3195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param offset an input output parameter. On input, it is the 3197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * offset into this string where the escape sequence is located, 3198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * after the initial backslash. On output, it is advanced after the 3199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * last character parsed. On error, it is not advanced at all. 3200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the character represented by the escape sequence at 3201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * offset, or (UChar32)0xFFFFFFFF on error. 3202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UnicodeString#unescape() 3203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see u_unescape() 3204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see u_unescapeAt() 3205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.0 3206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar32 unescapeAt(int32_t &offset) const; 3208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * ICU "poor man's RTTI", returns a UClassID for this class. 3211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.2 3213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru static UClassID U_EXPORT2 getStaticClassID(); 3215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * ICU "poor man's RTTI", returns a UClassID for the actual class. 3218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.2 3220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual UClassID getDynamicClassID() const; 3222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru //======================================== 3224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // Implementation methods 3225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru //======================================== 3226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruprotected: 3228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Implement Replaceable::getLength() (see jitterbug 1027). 3230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.4 3231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual int32_t getLength() const; 3233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The change in Replaceable to use virtual getCharAt() allows 3236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UnicodeString::charAt() to be inline again (see jitterbug 709). 3237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.4 3238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual UChar getCharAt(int32_t offset) const; 3240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 3242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The change in Replaceable to use virtual getChar32At() allows 3243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UnicodeString::char32At() to be inline again (see jitterbug 709). 3244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.4 3245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru virtual UChar32 getChar32At(int32_t offset) const; 3247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruprivate: 3249b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru // For char* constructors. Could be made public. 3250b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru UnicodeString &setToUTF8(const StringPiece &utf8); 3251b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru // For extract(char*). 3252b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru // We could make a toUTF8(target, capacity, errorCode) public but not 3253b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru // this version: New API will be cleaner if we make callers create substrings 3254b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru // rather than having start+length on every method, 3255b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru // and it should take a UErrorCode&. 3256b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru int32_t 3257b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru toUTF8(int32_t start, int32_t len, 3258b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru char *target, int32_t capacity) const; 3259b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru 3260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t 3262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru doCompare(int32_t start, 3263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 3264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 3265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 3267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int8_t doCompare(int32_t start, 3269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 3270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 3271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 3273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t 3275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru doCompareCodePointOrder(int32_t start, 3276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 3277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 3278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 3280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int8_t doCompareCodePointOrder(int32_t start, 3282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 3283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 3284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const; 3286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline int8_t 3288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru doCaseCompare(int32_t start, 3289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 3290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString &srcText, 3291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 3293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const; 3294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int8_t 3296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru doCaseCompare(int32_t start, 3297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 3298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 3299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 3301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const; 3302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t doIndexOf(UChar c, 3304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 3305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 3306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t doIndexOf(UChar32 c, 3308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 3309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 3310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t doLastIndexOf(UChar c, 3312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 3313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 3314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t doLastIndexOf(UChar32 c, 3316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 3317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length) const; 3318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru void doExtract(int32_t start, 3320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 3321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar *dst, 3322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t dstStart) const; 3323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline void doExtract(int32_t start, 3325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 3326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& target) const; 3327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UChar doCharAt(int32_t offset) const; 3329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& doReplace(int32_t start, 3331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 3332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 3333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength); 3335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& doReplace(int32_t start, 3337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length, 3338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 3339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength); 3341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& doReverse(int32_t start, 3343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t length); 3344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // calculate hash code 3346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t doHashCode(void) const; 3347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // get pointer to start of array 3349c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru // these do not check for kOpenGetBuffer, unlike the public getBuffer() function 3350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline UChar* getArrayStart(void); 3351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline const UChar* getArrayStart(void) const; 3352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3353c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru // A UnicodeString object (not necessarily its current buffer) 3354c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru // is writable unless it isBogus() or it has an "open" getBuffer(minCapacity). 3355c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru inline UBool isWritable() const; 3356c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru 3357c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru // Is the current buffer writable? 3358c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru inline UBool isBufferWritable() const; 3359c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru 3360c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru // None of the following does releaseArray(). 3361c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru inline void setLength(int32_t len); // sets only fShortLength and fLength 3362c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru inline void setToEmpty(); // sets fFlags=kShortString 3363c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru inline void setArray(UChar *array, int32_t len, int32_t capacity); // does not set fFlags 3364c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru 3365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // allocate the array; result may be fStackBuffer 3366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // sets refCount to 1 if appropriate 3367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // sets fArray, fCapacity, and fFlags 3368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // returns boolean for success or failure 3369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBool allocate(int32_t capacity); 3370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // release the array if owned 3372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru void releaseArray(void); 3373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // turn a bogus string into an empty one 3375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru void unBogus(); 3376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // implements assigment operator, copy constructor, and fastCopyFrom() 3378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString ©From(const UnicodeString &src, UBool fastCopy=FALSE); 3379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // Pin start and limit to acceptable values. 3381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline void pinIndex(int32_t& start) const; 3382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru inline void pinIndices(int32_t& start, 3383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t& length) const; 3384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_CONVERSION 3386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* Internal extract() using UConverter. */ 3388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t doExtract(int32_t start, int32_t length, 3389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru char *dest, int32_t destCapacity, 3390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UConverter *cnv, 3391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode &errorCode) const; 3392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* 3394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Real constructor for converting from codepage data. 3395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It assumes that it is called with !fRefCounted. 3396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If <code>codepage==0</code>, then the default converter 3398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is used for the platform encoding. 3399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If <code>codepage</code> is an empty string (<code>""</code>), 3400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * then a simple conversion is performed on the codepage-invariant 3401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * subset ("invariant characters") of the platform encoding. See utypes.h. 3402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru void doCodepageCreate(const char *codepageData, 3404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t dataLength, 3405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const char *codepage); 3406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* 3408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Worker function for creating a UnicodeString from 3409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a codepage string using a UConverter. 3410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru void 3412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru doCodepageCreate(const char *codepageData, 3413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t dataLength, 3414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UConverter *converter, 3415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode &status); 3416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 3418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* 3420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is called when write access to the array 3421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is necessary. 3422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * We need to make a copy of the array if 3424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the buffer is read-only, or 3425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the buffer is refCounted (shared), and refCount>1, or 3426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the buffer is too small. 3427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Return FALSE if memory could not be allocated. 3429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBool cloneArrayIfNeeded(int32_t newCapacity = -1, 3431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t growCapacity = -1, 3432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBool doCopyArray = TRUE, 3433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t **pBufferToDelete = 0, 3434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBool forceClone = FALSE); 3435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3436103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius /** 3437103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * Common function for UnicodeString case mappings. 3438103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * The stringCaseMapper has the same type UStringCaseMapper 3439103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * as in ustr_imp.h for ustrcase_map(). 3440103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius */ 3441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString & 3442103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius caseMap(const UCaseMap *csm, UStringCaseMapper *stringCaseMapper); 3443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // ref counting 3445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru void addRef(void); 3446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t removeRef(void); 3447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t refCount(void) const; 3448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // constants 3450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru enum { 3451b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho // Set the stack buffer size so that sizeof(UnicodeString) is, 3452b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho // naturally (without padding), a multiple of sizeof(pointer). 3453b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho US_STACKBUF_SIZE= sizeof(void *)==4 ? 13 : 15, // Size of stack buffer for short strings 3454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru kInvalidUChar=0xffff, // invalid UChar index 3455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru kGrowSize=128, // grow size for this buffer 3456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru kInvalidHashCode=0, // invalid hash code 3457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru kEmptyHashCode=1, // hash code for empty string 3458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // bit flag values for fFlags 3460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru kIsBogus=1, // this string is bogus, i.e., not valid or NULL 3461b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho kUsingStackBuffer=2,// using fUnion.fStackBuffer instead of fUnion.fFields 3462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru kRefCounted=4, // there is a refCount field before the characters in fArray 3463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru kBufferIsReadonly=8,// do not write to this buffer 3464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru kOpenGetBuffer=16, // getBuffer(minCapacity) was called (is "open"), 3465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // and releaseBuffer(newLength) must be called 3466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // combined values for convenience 3468b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru kShortString=kUsingStackBuffer, 3469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru kLongString=kRefCounted, 3470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru kReadonlyAlias=kBufferIsReadonly, 3471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru kWritableAlias=0 3472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru }; 3473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru friend class StringThreadTest; 3475b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho friend class UnicodeStringAppendable; 3476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3477c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru union StackBufferOrFields; // forward declaration necessary before friend declaration 3478c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru friend union StackBufferOrFields; // make US_STACKBUF_SIZE visible inside fUnion 3479c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru 3480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* 3481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The following are all the class fields that are stored 3482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in each UnicodeString object. 3483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Note that UnicodeString has virtual functions, 3484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * therefore there is an implicit vtable pointer 3485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * as the first real field. 3486b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * The fields should be aligned such that no padding is necessary. 3487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * On 32-bit machines, the size should be 32 bytes, 3488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * on 64-bit machines (8-byte pointers), it should be 40 bytes. 3489b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 3490b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * We use a hack to achieve this. 3491b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 3492b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * With at least some compilers, each of the following is forced to 3493b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * a multiple of sizeof(pointer) [the largest field base unit here is a data pointer], 3494b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * rounded up with additional padding if the fields do not already fit that requirement: 3495b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * - sizeof(class UnicodeString) 3496b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * - offsetof(UnicodeString, fUnion) 3497b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * - sizeof(fUnion) 3498b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * - sizeof(fFields) 3499b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 3500b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * In order to avoid padding, we make sizeof(fStackBuffer)=16 (=8 UChars) 3501b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * which is at least as large as sizeof(fFields) on 32-bit and 64-bit machines. 3502b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * (Padding at the end of fFields is ok: 3503b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * As long as there is no padding after fStackBuffer, it is not wasted space.) 3504b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 3505b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * We further assume that the compiler does not reorder the fields, 3506b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * so that fRestOfStackBuffer (which holds a few more UChars) immediately follows after fUnion, 3507b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * with at most some padding (but no other field) in between. 3508b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * (Padding there would be wasted space, but functionally harmless.) 3509b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * 3510b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * We use a few more sizeof(pointer)'s chunks of space with 3511b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * fRestOfStackBuffer, fShortLength and fFlags, 3512b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * to get up exactly to the intended sizeof(UnicodeString). 3513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // (implicit) *vtable; 3515c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru union StackBufferOrFields { 3516c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru // fStackBuffer is used iff (fFlags&kUsingStackBuffer) 3517c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru // else fFields is used 3518b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UChar fStackBuffer[8]; // buffer for short strings, together with fRestOfStackBuffer 3519c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru struct { 3520b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UChar *fArray; // the Unicode data 3521b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho int32_t fCapacity; // capacity of fArray (in UChars) 3522b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho int32_t fLength; // number of characters in fArray if >127; else undefined 3523c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru } fFields; 3524c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru } fUnion; 3525b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UChar fRestOfStackBuffer[US_STACKBUF_SIZE-8]; 3526b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho int8_t fShortLength; // 0..127: length <0: real length is in fUnion.fFields.fLength 3527b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho uint8_t fFlags; // bit flags: see constants above 3528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 3529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 3531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Create a new UnicodeString with the concatenation of two others. 3532b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param s1 The first string to be copied to the new one. 3534b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param s2 The second string to be copied to the new one, after s1. 3535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return UnicodeString(s1).append(s2) 3536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.8 3537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 3538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_COMMON_API UnicodeString U_EXPORT2 3539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruoperator+ (const UnicodeString &s1, const UnicodeString &s2); 3540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//======================================== 3542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Inline members 3543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//======================================== 3544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//======================================== 3546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Privates 3547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//======================================== 3548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline void 3550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::pinIndex(int32_t& start) const 3551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 3552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // pin index 3553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(start < 0) { 3554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru start = 0; 3555c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru } else if(start > length()) { 3556c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru start = length(); 3557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 3558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline void 3561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::pinIndices(int32_t& start, 3562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t& _length) const 3563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 3564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // pin indices 3565c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru int32_t len = length(); 3566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(start < 0) { 3567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru start = 0; 3568c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru } else if(start > len) { 3569c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru start = len; 3570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 3571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(_length < 0) { 3572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru _length = 0; 3573c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru } else if(_length > (len - start)) { 3574c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru _length = (len - start); 3575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 3576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UChar* 3579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::getArrayStart() 3580c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return (fFlags&kUsingStackBuffer) ? fUnion.fStackBuffer : fUnion.fFields.fArray; } 3581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline const UChar* 3583b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::getArrayStart() const 3584c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return (fFlags&kUsingStackBuffer) ? fUnion.fStackBuffer : fUnion.fFields.fArray; } 3585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//======================================== 3587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Read-only implementation methods 3588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//======================================== 3589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3590b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::length() const 3591c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return fShortLength>=0 ? fShortLength : fUnion.fFields.fLength; } 3592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::getCapacity() const 3595c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return (fFlags&kUsingStackBuffer) ? US_STACKBUF_SIZE : fUnion.fFields.fCapacity; } 3596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::hashCode() const 3599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doHashCode(); } 3600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3601b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 3602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::isBogus() const 3603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return (UBool)(fFlags & kIsBogus); } 3604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3605c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queruinline UBool 3606c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste QueruUnicodeString::isWritable() const 3607c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return (UBool)!(fFlags&(kOpenGetBuffer|kIsBogus)); } 3608c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru 3609c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queruinline UBool 3610c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste QueruUnicodeString::isBufferWritable() const 3611c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ 3612c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return (UBool)( 3613c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru !(fFlags&(kOpenGetBuffer|kIsBogus|kBufferIsReadonly)) && 3614c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru (!(fFlags&kRefCounted) || refCount()==1)); 3615c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru} 3616c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru 3617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline const UChar * 3618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::getBuffer() const { 3619c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru if(fFlags&(kIsBogus|kOpenGetBuffer)) { 3620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return 0; 3621c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru } else if(fFlags&kUsingStackBuffer) { 3622c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return fUnion.fStackBuffer; 3623c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru } else { 3624c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return fUnion.fFields.fArray; 3625b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 3626b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3627b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3628b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//======================================== 3629b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Read-only alias methods 3630b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//======================================== 3631b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3632b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::doCompare(int32_t start, 3633c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru int32_t thisLength, 3634b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 3635b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3636b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const 3637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 3638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(srcText.isBogus()) { 3639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise 3640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 3641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcText.pinIndices(srcStart, srcLength); 3642c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength); 3643b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 3644b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3645b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3646b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 3647b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::operator== (const UnicodeString& text) const 3648b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 3649b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(isBogus()) { 3650b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return text.isBogus(); 3651b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 3652c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru int32_t len = length(), textLength = text.length(); 3653b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return 3654b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru !text.isBogus() && 3655c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru len == textLength && 3656c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru doCompare(0, len, text, 0, textLength) == 0; 3657b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 3658b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3659b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3660b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 3661b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::operator!= (const UnicodeString& text) const 3662b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return (! operator==(text)); } 3663b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3664b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 3665b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::operator> (const UnicodeString& text) const 3666c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doCompare(0, length(), text, 0, text.length()) == 1; } 3667b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3668b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 3669b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::operator< (const UnicodeString& text) const 3670c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doCompare(0, length(), text, 0, text.length()) == -1; } 3671b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3672b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 3673b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::operator>= (const UnicodeString& text) const 3674c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doCompare(0, length(), text, 0, text.length()) != -1; } 3675b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3676b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 3677b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::operator<= (const UnicodeString& text) const 3678c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doCompare(0, length(), text, 0, text.length()) != 1; } 3679b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3680b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3681b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compare(const UnicodeString& text) const 3682c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doCompare(0, length(), text, 0, text.length()); } 3683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compare(int32_t start, 3686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 3687b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText) const 3688c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doCompare(start, _length, srcText, 0, srcText.length()); } 3689b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3690b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3691b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compare(const UChar *srcChars, 3692b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const 3693c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doCompare(0, length(), srcChars, 0, srcLength); } 3694b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3695b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3696b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compare(int32_t start, 3697b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 3698b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 3699b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3700b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const 3701b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doCompare(start, _length, srcText, srcStart, srcLength); } 3702b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compare(int32_t start, 3705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 3706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars) const 3707b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doCompare(start, _length, srcChars, 0, _length); } 3708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3709b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compare(int32_t start, 3711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 3712b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 3713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const 3715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doCompare(start, _length, srcChars, srcStart, srcLength); } 3716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3717b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3718b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compareBetween(int32_t start, 3719b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 3720b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 3721b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3722b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLimit) const 3723b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doCompare(start, limit - start, 3724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcText, srcStart, srcLimit - srcStart); } 3725b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3726b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::doCompareCodePointOrder(int32_t start, 3728c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru int32_t thisLength, 3729b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 3730b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const 3732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 3733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(srcText.isBogus()) { 3734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise 3735b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 3736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcText.pinIndices(srcStart, srcLength); 3737c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doCompareCodePointOrder(start, thisLength, srcText.getArrayStart(), srcStart, srcLength); 3738b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 3739b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3740b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3741b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3742b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compareCodePointOrder(const UnicodeString& text) const 3743c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doCompareCodePointOrder(0, length(), text, 0, text.length()); } 3744b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3745b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3746b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compareCodePointOrder(int32_t start, 3747b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 3748b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText) const 3749c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doCompareCodePointOrder(start, _length, srcText, 0, srcText.length()); } 3750b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3751b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3752b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compareCodePointOrder(const UChar *srcChars, 3753b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const 3754c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doCompareCodePointOrder(0, length(), srcChars, 0, srcLength); } 3755b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3756b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3757b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compareCodePointOrder(int32_t start, 3758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 3759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 3760b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const 3762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doCompareCodePointOrder(start, _length, srcText, srcStart, srcLength); } 3763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3765b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compareCodePointOrder(int32_t start, 3766b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 3767b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars) const 3768b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doCompareCodePointOrder(start, _length, srcChars, 0, _length); } 3769b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3770b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3771b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compareCodePointOrder(int32_t start, 3772b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 3773b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 3774b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3775b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const 3776b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doCompareCodePointOrder(start, _length, srcChars, srcStart, srcLength); } 3777b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3778b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3779b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::compareCodePointOrderBetween(int32_t start, 3780b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 3781b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 3782b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3783b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLimit) const 3784b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doCompareCodePointOrder(start, limit - start, 3785b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcText, srcStart, srcLimit - srcStart); } 3786b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3787b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3788b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::doCaseCompare(int32_t start, 3789c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru int32_t thisLength, 3790b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString &srcText, 3791b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3792b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 3793b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const 3794b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 3795b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(srcText.isBogus()) { 3796b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise 3797b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 3798b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcText.pinIndices(srcStart, srcLength); 3799c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doCaseCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength, options); 3800b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 3801b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3802b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3803b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3804b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::caseCompare(const UnicodeString &text, uint32_t options) const { 3805c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doCaseCompare(0, length(), text, 0, text.length(), options); 3806b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3807b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3808b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3809b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::caseCompare(int32_t start, 3810b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 3811b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString &srcText, 3812b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const { 3813c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doCaseCompare(start, _length, srcText, 0, srcText.length(), options); 3814b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3815b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3816b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3817b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::caseCompare(const UChar *srcChars, 3818b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 3819b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const { 3820c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doCaseCompare(0, length(), srcChars, 0, srcLength, options); 3821b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3822b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3823b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3824b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::caseCompare(int32_t start, 3825b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 3826b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString &srcText, 3827b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3828b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 3829b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const { 3830b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return doCaseCompare(start, _length, srcText, srcStart, srcLength, options); 3831b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3832b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3833b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3834b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::caseCompare(int32_t start, 3835b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 3836b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 3837b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const { 3838b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return doCaseCompare(start, _length, srcChars, 0, _length, options); 3839b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3840b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3841b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3842b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::caseCompare(int32_t start, 3843b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 3844b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 3845b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3846b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 3847b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const { 3848b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return doCaseCompare(start, _length, srcChars, srcStart, srcLength, options); 3849b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3850b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3851b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int8_t 3852b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::caseCompareBetween(int32_t start, 3853b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 3854b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString &srcText, 3855b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3856b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLimit, 3857b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options) const { 3858b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return doCaseCompare(start, limit - start, srcText, srcStart, srcLimit - srcStart, options); 3859b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3860b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3861b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3862b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::indexOf(const UnicodeString& srcText, 3863b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3864b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 3865b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 3866b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length) const 3867b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 3868b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(!srcText.isBogus()) { 3869b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcText.pinIndices(srcStart, srcLength); 3870b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(srcLength > 0) { 3871b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return indexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length); 3872b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 3873b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 3874b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return -1; 3875b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3876b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3877b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3878b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::indexOf(const UnicodeString& text) const 3879c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return indexOf(text, 0, text.length(), 0, length()); } 3880b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3881b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3882b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::indexOf(const UnicodeString& text, 3883b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const { 3884b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru pinIndex(start); 3885c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return indexOf(text, 0, text.length(), start, length() - start); 3886b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3887b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3888b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3889b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::indexOf(const UnicodeString& text, 3890b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 3891b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length) const 3892c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return indexOf(text, 0, text.length(), start, _length); } 3893b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3894b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3895b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::indexOf(const UChar *srcChars, 3896b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 3897b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const { 3898b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru pinIndex(start); 3899c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return indexOf(srcChars, 0, srcLength, start, length() - start); 3900b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3901b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3902b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3903b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::indexOf(const UChar *srcChars, 3904b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 3905b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 3906b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length) const 3907b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return indexOf(srcChars, 0, srcLength, start, _length); } 3908b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3909b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3910b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::indexOf(UChar c, 3911b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 3912b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length) const 3913b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doIndexOf(c, start, _length); } 3914b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3915b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3916b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::indexOf(UChar32 c, 3917b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 3918b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length) const 3919b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doIndexOf(c, start, _length); } 3920b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3921b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3922b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::indexOf(UChar c) const 3923c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doIndexOf(c, 0, length()); } 3924b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3925b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3926b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::indexOf(UChar32 c) const 3927c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return indexOf(c, 0, length()); } 3928b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3929b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3930b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::indexOf(UChar c, 3931b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const { 3932b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru pinIndex(start); 3933c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doIndexOf(c, start, length() - start); 3934b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3935b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3936b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3937b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::indexOf(UChar32 c, 3938b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const { 3939b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru pinIndex(start); 3940c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return indexOf(c, start, length() - start); 3941b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3942b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3943b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3944b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::lastIndexOf(const UChar *srcChars, 3945b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 3946b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 3947b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length) const 3948b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return lastIndexOf(srcChars, 0, srcLength, start, _length); } 3949b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3950b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3951b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::lastIndexOf(const UChar *srcChars, 3952b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 3953b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const { 3954b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru pinIndex(start); 3955c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return lastIndexOf(srcChars, 0, srcLength, start, length() - start); 3956b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3957b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3958b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3959b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::lastIndexOf(const UnicodeString& srcText, 3960b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 3961b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength, 3962b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 3963b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length) const 3964b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 3965b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(!srcText.isBogus()) { 3966b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcText.pinIndices(srcStart, srcLength); 3967b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(srcLength > 0) { 3968b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return lastIndexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length); 3969b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 3970b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 3971b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return -1; 3972b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3973b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3974b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3975b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::lastIndexOf(const UnicodeString& text, 3976b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 3977b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length) const 3978c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return lastIndexOf(text, 0, text.length(), start, _length); } 3979b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3980b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3981b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::lastIndexOf(const UnicodeString& text, 3982b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const { 3983b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru pinIndex(start); 3984c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return lastIndexOf(text, 0, text.length(), start, length() - start); 3985b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 3986b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3987b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3988b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::lastIndexOf(const UnicodeString& text) const 3989c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return lastIndexOf(text, 0, text.length(), 0, length()); } 3990b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3991b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3992b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::lastIndexOf(UChar c, 3993b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 3994b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length) const 3995b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doLastIndexOf(c, start, _length); } 3996b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3997b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 3998b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::lastIndexOf(UChar32 c, 3999b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, 4000b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length) const { 4001b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return doLastIndexOf(c, start, _length); 4002b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4003b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4004b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 4005b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::lastIndexOf(UChar c) const 4006c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doLastIndexOf(c, 0, length()); } 4007b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4008b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 4009b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::lastIndexOf(UChar32 c) const { 4010c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return lastIndexOf(c, 0, length()); 4011b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4012b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4013b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 4014b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::lastIndexOf(UChar c, 4015b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const { 4016b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru pinIndex(start); 4017c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doLastIndexOf(c, start, length() - start); 4018b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4019b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4020b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 4021b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::lastIndexOf(UChar32 c, 4022b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start) const { 4023b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru pinIndex(start); 4024c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return lastIndexOf(c, start, length() - start); 4025b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4026b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4027b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 4028b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::startsWith(const UnicodeString& text) const 4029c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return compare(0, text.length(), text, 0, text.length()) == 0; } 4030b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4031b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 4032b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::startsWith(const UnicodeString& srcText, 4033b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 4034b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const 4035b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doCompare(0, srcLength, srcText, srcStart, srcLength) == 0; } 4036b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4037b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 4038b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoUnicodeString::startsWith(const UChar *srcChars, int32_t srcLength) const { 4039b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho if(srcLength < 0) { 4040b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho srcLength = u_strlen(srcChars); 4041b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho } 4042b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho return doCompare(0, srcLength, srcChars, 0, srcLength) == 0; 4043b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho} 4044b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4045b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 4046b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoUnicodeString::startsWith(const UChar *srcChars, int32_t srcStart, int32_t srcLength) const { 4047b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho if(srcLength < 0) { 4048b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho srcLength = u_strlen(srcChars); 4049b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho } 4050b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho return doCompare(0, srcLength, srcChars, srcStart, srcLength) == 0; 4051b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho} 4052b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4053b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 4054b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::endsWith(const UnicodeString& text) const 4055c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doCompare(length() - text.length(), text.length(), 4056c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru text, 0, text.length()) == 0; } 4057b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4058b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 4059b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::endsWith(const UnicodeString& srcText, 4060b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 4061b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const { 4062b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcText.pinIndices(srcStart, srcLength); 4063c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doCompare(length() - srcLength, srcLength, 4064b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcText, srcStart, srcLength) == 0; 4065b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4066b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4067b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 4068b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::endsWith(const UChar *srcChars, 4069b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const { 4070b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(srcLength < 0) { 4071b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcLength = u_strlen(srcChars); 4072b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 4073c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doCompare(length() - srcLength, srcLength, 4074b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcChars, 0, srcLength) == 0; 4075b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4076b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4077b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 4078b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::endsWith(const UChar *srcChars, 4079b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 4080b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) const { 4081b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(srcLength < 0) { 4082b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcLength = u_strlen(srcChars + srcStart); 4083b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 4084c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doCompare(length() - srcLength, srcLength, 4085b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcChars, srcStart, srcLength) == 0; 4086b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4087b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4088b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//======================================== 4089b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// replace 4090b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//======================================== 4091b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4092b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::replace(int32_t start, 4093b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 4094b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText) 4095c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doReplace(start, _length, srcText, 0, srcText.length()); } 4096b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4097b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4098b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::replace(int32_t start, 4099b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 4100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 4101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 4102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) 4103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doReplace(start, _length, srcText, srcStart, srcLength); } 4104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::replace(int32_t start, 4107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 4108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 4109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) 4110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doReplace(start, _length, srcChars, 0, srcLength); } 4111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::replace(int32_t start, 4114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 4115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 4116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 4117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) 4118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doReplace(start, _length, srcChars, srcStart, srcLength); } 4119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::replace(int32_t start, 4122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 4123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar srcChar) 4124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doReplace(start, _length, &srcChar, 0, 1); } 4125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::replaceBetween(int32_t start, 4128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 4129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText) 4130c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doReplace(start, limit - start, srcText, 0, srcText.length()); } 4131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::replaceBetween(int32_t start, 4134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 4135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 4136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 4137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLimit) 4138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doReplace(start, limit - start, srcText, srcStart, srcLimit - srcStart); } 4139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::findAndReplace(const UnicodeString& oldText, 4142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& newText) 4143c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return findAndReplace(0, length(), oldText, 0, oldText.length(), 4144c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru newText, 0, newText.length()); } 4145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::findAndReplace(int32_t start, 4148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 4149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& oldText, 4150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& newText) 4151c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return findAndReplace(start, _length, oldText, 0, oldText.length(), 4152c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru newText, 0, newText.length()); } 4153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// ============================ 4155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// extract 4156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// ============================ 4157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline void 4158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::doExtract(int32_t start, 4159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 4160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& target) const 4161c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ target.replace(0, target.length(), *this, start, _length); } 4162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline void 4164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::extract(int32_t start, 4165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 4166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar *target, 4167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t targetStart) const 4168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ doExtract(start, _length, target, targetStart); } 4169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline void 4171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::extract(int32_t start, 4172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 4173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString& target) const 4174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ doExtract(start, _length, target); } 4175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_CONVERSION 4177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t 4179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::extract(int32_t start, 4180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length, 4181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru char *dst, 4182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const char *codepage) const 4183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 4185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // This dstSize value will be checked explicitly 4186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return extract(start, _length, dst, dst!=0 ? 0xffffffff : 0, codepage); 4187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 4190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline void 4192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::extractBetween(int32_t start, 4193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit, 4194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar *dst, 4195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t dstStart) const { 4196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru pinIndex(start); 4197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru pinIndex(limit); 4198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru doExtract(start, limit - start, dst, dstStart); 4199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 420150294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoinline UnicodeString 420250294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoUnicodeString::tempSubStringBetween(int32_t start, int32_t limit) const { 420350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return tempSubString(start, limit - start); 420450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho} 420550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 4206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UChar 4207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::doCharAt(int32_t offset) const 4208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 4209c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru if((uint32_t)offset < (uint32_t)length()) { 4210c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return getArrayStart()[offset]; 4211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 4212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return kInvalidUChar; 4213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 4214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UChar 4217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::charAt(int32_t offset) const 4218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doCharAt(offset); } 4219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UChar 4221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::operator[] (int32_t offset) const 4222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doCharAt(offset); } 4223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 4225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::isEmpty() const { 4226c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return fShortLength == 0; 4227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//======================================== 4230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Write implementation methods 4231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//======================================== 4232c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queruinline void 4233c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste QueruUnicodeString::setLength(int32_t len) { 4234c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru if(len <= 127) { 4235c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru fShortLength = (int8_t)len; 4236c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru } else { 4237c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru fShortLength = (int8_t)-1; 4238c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru fUnion.fFields.fLength = len; 4239c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru } 4240c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru} 4241c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru 4242c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queruinline void 4243c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste QueruUnicodeString::setToEmpty() { 4244c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru fShortLength = 0; 4245c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru fFlags = kShortString; 4246c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru} 4247c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru 4248c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queruinline void 4249c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste QueruUnicodeString::setArray(UChar *array, int32_t len, int32_t capacity) { 4250c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru setLength(len); 4251c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru fUnion.fFields.fArray = array; 4252c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru fUnion.fFields.fCapacity = capacity; 4253c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru} 4254c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru 4255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline const UChar * 4256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::getTerminatedBuffer() { 4257c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru if(!isWritable()) { 4258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return 0; 4259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 4260c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru UChar *array = getArrayStart(); 4261c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru int32_t len = length(); 426250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(len < getCapacity() && ((fFlags&kRefCounted) == 0 || refCount() == 1)) { 426350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho /* 426450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * kRefCounted: Do not write the NUL if the buffer is shared. 426550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * That is mostly safe, except when the length of one copy was modified 426650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * without copy-on-write, e.g., via truncate(newLength) or remove(void). 426750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Then the NUL would be written into the middle of another copy's string. 426850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 426950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(!(fFlags&kBufferIsReadonly)) { 427050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho /* 427150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * We must not write to a readonly buffer, but it is known to be 427250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * NUL-terminated if len<capacity. 427350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * A shared, allocated buffer (refCount()>1) must not have its contents 427450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * modified, but the NUL at [len] is beyond the string contents, 427550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * and multiple string objects and threads writing the same NUL into the 427650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * same location is harmless. 427750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * In all other cases, the buffer is fully writable and it is anyway safe 427850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * to write the NUL. 427950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 428050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Note: An earlier version of this code tested whether there is a NUL 428150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * at [len] already, but, while safe, it generated lots of warnings from 428250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * tools like valgrind and Purify. 428350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 428450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho array[len] = 0; 428550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 4286c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return array; 428750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } else if(cloneArrayIfNeeded(len+1)) { 4288c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru array = getArrayStart(); 4289c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru array[len] = 0; 4290c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return array; 4291c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru } else { 4292c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return 0; 4293c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru } 4294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 4295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::operator= (UChar ch) 4299c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doReplace(0, length(), &ch, 0, 1); } 4300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::operator= (UChar32 ch) 4303c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return replace(0, length(), ch); } 4304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::setTo(const UnicodeString& srcText, 4307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 4308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) 4309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 4310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru unBogus(); 4311c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doReplace(0, length(), srcText, srcStart, srcLength); 4312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::setTo(const UnicodeString& srcText, 4316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart) 4317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 4318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru unBogus(); 4319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru srcText.pinIndex(srcStart); 4320c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doReplace(0, length(), srcText, srcStart, srcText.length() - srcStart); 4321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::setTo(const UnicodeString& srcText) 4325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 4326b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho return copyFrom(srcText); 4327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::setTo(const UChar *srcChars, 4331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) 4332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 4333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru unBogus(); 4334c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doReplace(0, length(), srcChars, 0, srcLength); 4335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::setTo(UChar srcChar) 4339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 4340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru unBogus(); 4341c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return doReplace(0, length(), &srcChar, 0, 1); 4342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::setTo(UChar32 srcChar) 4346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 4347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru unBogus(); 4348c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru return replace(0, length(), srcChar); 4349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::append(const UnicodeString& srcText, 4353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 4354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) 4355c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doReplace(length(), 0, srcText, srcStart, srcLength); } 4356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::append(const UnicodeString& srcText) 4359c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doReplace(length(), 0, srcText, 0, srcText.length()); } 4360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::append(const UChar *srcChars, 4363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 4364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) 4365c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doReplace(length(), 0, srcChars, srcStart, srcLength); } 4366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::append(const UChar *srcChars, 4369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) 4370c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doReplace(length(), 0, srcChars, 0, srcLength); } 4371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::append(UChar srcChar) 4374c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doReplace(length(), 0, &srcChar, 0, 1); } 4375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::operator+= (UChar ch) 4378c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doReplace(length(), 0, &ch, 0, 1); } 4379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::operator+= (UChar32 ch) { 4382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return append(ch); 4383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::operator+= (const UnicodeString& srcText) 4387c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doReplace(length(), 0, srcText, 0, srcText.length()); } 4388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::insert(int32_t start, 4391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText, 4392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 4393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) 4394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doReplace(start, 0, srcText, srcStart, srcLength); } 4395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::insert(int32_t start, 4398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UnicodeString& srcText) 4399c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doReplace(start, 0, srcText, 0, srcText.length()); } 4400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::insert(int32_t start, 4403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 4404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcStart, 4405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) 4406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doReplace(start, 0, srcChars, srcStart, srcLength); } 4407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::insert(int32_t start, 4410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *srcChars, 4411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t srcLength) 4412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doReplace(start, 0, srcChars, 0, srcLength); } 4413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::insert(int32_t start, 4416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar srcChar) 4417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doReplace(start, 0, &srcChar, 0, 1); } 4418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::insert(int32_t start, 4421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar32 srcChar) 4422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return replace(start, 0, srcChar); } 4423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::remove() 4427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 4428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // remove() of a bogus string makes the string empty and non-bogus 442950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho // we also un-alias a read-only alias to deal with NUL-termination 443050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho // issues with getTerminatedBuffer() 443150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(fFlags & (kIsBogus|kBufferIsReadonly)) { 443250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho setToEmpty(); 4433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 443450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho fShortLength = 0; 4435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 4436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return *this; 4437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::remove(int32_t start, 4441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length) 4442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 4443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(start <= 0 && _length == INT32_MAX) { 4444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // remove(guaranteed everything) of a bogus string makes the string empty and non-bogus 4445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return remove(); 4446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 4447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return doReplace(start, _length, NULL, 0, 0); 4448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::removeBetween(int32_t start, 4452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t limit) 4453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doReplace(start, limit - start, NULL, 0, 0); } 4454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 445550294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoinline UnicodeString & 445650294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoUnicodeString::retainBetween(int32_t start, int32_t limit) { 445750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho truncate(limit); 445850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho return doReplace(0, start, NULL, 0, 0); 445950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho} 446050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 4461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UBool 4462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::truncate(int32_t targetLength) 4463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 4464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(isBogus() && targetLength == 0) { 4465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // truncate(0) of a bogus string makes the string empty and non-bogus 4466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru unBogus(); 4467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return FALSE; 4468c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru } else if((uint32_t)targetLength < (uint32_t)length()) { 4469c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru setLength(targetLength); 447050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho if(fFlags&kBufferIsReadonly) { 447150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho fUnion.fFields.fCapacity = targetLength; // not NUL-terminated any more 447250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho } 4473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return TRUE; 4474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 4475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return FALSE; 4476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 4477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 4478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::reverse() 4481c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{ return doReverse(0, length()); } 4482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& 4484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString::reverse(int32_t start, 4485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t _length) 4486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return doReverse(start, _length); } 4487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_NAMESPACE_END 4489b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 4491