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