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