1999-12-28 23:39:02 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
2012-06-06 17:35:12 +00:00
|
|
|
* Copyright (C) 1998-2012, International Business Machines
|
1999-12-28 23:39:02 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
|
|
|
*
|
|
|
|
* File unistr.h
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 09/25/98 stephen Creation.
|
|
|
|
* 11/11/98 stephen Changed per 11/9 code review.
|
|
|
|
* 04/20/99 stephen Overhauled per 4/16 code review.
|
|
|
|
* 11/18/99 aliu Made to inherit from Replaceable. Added method
|
|
|
|
* handleReplaceBetween(); other methods unchanged.
|
2001-06-26 17:57:53 +00:00
|
|
|
* 06/25/01 grhoten Remove dependency on iostream.
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef UNISTR_H
|
|
|
|
#define UNISTR_H
|
|
|
|
|
2005-06-22 22:39:36 +00:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* \brief C++ API: Unicode String
|
|
|
|
*/
|
|
|
|
|
2009-03-06 19:19:00 +00:00
|
|
|
#include "unicode/utypes.h"
|
1999-12-28 23:39:02 +00:00
|
|
|
#include "unicode/rep.h"
|
2009-03-06 19:19:00 +00:00
|
|
|
#include "unicode/std_string.h"
|
|
|
|
#include "unicode/stringpiece.h"
|
|
|
|
#include "unicode/bytestream.h"
|
2011-06-03 05:23:57 +00:00
|
|
|
#include "unicode/ucasemap.h"
|
2001-10-08 23:26:58 +00:00
|
|
|
|
2001-09-18 01:12:14 +00:00
|
|
|
struct UConverter; // unicode/ucnv.h
|
2002-03-12 23:15:41 +00:00
|
|
|
class StringThreadTest;
|
2001-09-18 01:12:14 +00:00
|
|
|
|
2002-05-24 22:22:16 +00:00
|
|
|
#ifndef U_COMPARE_CODE_POINT_ORDER
|
|
|
|
/* see also ustring.h and unorm.h */
|
|
|
|
/**
|
|
|
|
* Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc:
|
|
|
|
* Compare strings in code point order instead of code unit order.
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-05-24 22:22:16 +00:00
|
|
|
*/
|
|
|
|
#define U_COMPARE_CODE_POINT_ORDER 0x8000
|
|
|
|
#endif
|
|
|
|
|
2002-11-26 23:32:55 +00:00
|
|
|
#ifndef USTRING_H
|
2006-08-29 21:55:46 +00:00
|
|
|
/**
|
|
|
|
* \ingroup ustring_ustrlen
|
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE int32_t U_EXPORT2
|
2002-11-26 23:32:55 +00:00
|
|
|
u_strlen(const UChar *s);
|
|
|
|
#endif
|
|
|
|
|
2012-09-11 20:51:51 +00:00
|
|
|
/**
|
|
|
|
* \def U_STRING_CASE_MAPPER_DEFINED
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
|
2011-06-03 05:23:57 +00:00
|
|
|
#ifndef U_STRING_CASE_MAPPER_DEFINED
|
|
|
|
#define U_STRING_CASE_MAPPER_DEFINED
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal string case mapping function type.
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
typedef int32_t U_CALLCONV
|
|
|
|
UStringCaseMapper(const UCaseMap *csm,
|
|
|
|
UChar *dest, int32_t destCapacity,
|
|
|
|
const UChar *src, int32_t srcLength,
|
|
|
|
UErrorCode *pErrorCode);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2011-02-03 22:07:22 +00:00
|
|
|
class BreakIterator; // unicode/brkiter.h
|
2001-01-02 19:37:08 +00:00
|
|
|
class Locale; // unicode/locid.h
|
2001-10-08 23:26:58 +00:00
|
|
|
class StringCharacterIterator;
|
2011-02-03 22:07:22 +00:00
|
|
|
class UnicodeStringAppendable; // unicode/appendable.h
|
2000-03-29 01:13:49 +00:00
|
|
|
|
2001-06-26 17:57:53 +00:00
|
|
|
/* The <iostream> include has been moved to unicode/ustream.h */
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-26 22:58:39 +00:00
|
|
|
/**
|
|
|
|
* Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor
|
|
|
|
* which constructs a Unicode string from an invariant-character char * string.
|
|
|
|
* About invariant characters see utypes.h.
|
|
|
|
* This constructor has no runtime dependency on conversion code and is
|
|
|
|
* therefore recommended over ones taking a charset name string
|
|
|
|
* (where the empty string "" indicates invariant-character conversion).
|
|
|
|
*
|
2006-01-18 03:34:19 +00:00
|
|
|
* @stable ICU 3.2
|
2004-08-26 22:58:39 +00:00
|
|
|
*/
|
2011-07-06 04:03:35 +00:00
|
|
|
#define US_INV icu::UnicodeString::kInvariant
|
2004-08-26 22:58:39 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Unicode String literals in C++.
|
|
|
|
* Dependent on the platform properties, different UnicodeString
|
|
|
|
* constructors should be used to create a UnicodeString object from
|
|
|
|
* a string literal.
|
|
|
|
* The macros are defined for maximum performance.
|
|
|
|
* They work only for strings that contain "invariant characters", i.e.,
|
|
|
|
* only latin letters, digits, and some punctuation.
|
|
|
|
* See utypes.h for details.
|
|
|
|
*
|
|
|
|
* The string parameter must be a C string literal.
|
|
|
|
* The length of the string, not including the terminating
|
|
|
|
* <code>NUL</code>, must be specified as a constant.
|
|
|
|
* The U_STRING_DECL macro should be invoked exactly once for one
|
|
|
|
* such string variable before it is used.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2007-05-30 22:28:35 +00:00
|
|
|
#if defined(U_DECLARE_UTF16)
|
2011-07-06 04:03:35 +00:00
|
|
|
# define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)U_DECLARE_UTF16(cs), _length)
|
2007-05-30 22:28:35 +00:00
|
|
|
#elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16)))
|
2011-07-06 04:03:35 +00:00
|
|
|
# define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)L ## cs, _length)
|
1999-12-28 23:39:02 +00:00
|
|
|
#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY
|
2011-07-06 04:03:35 +00:00
|
|
|
# define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)cs, _length)
|
1999-12-28 23:39:02 +00:00
|
|
|
#else
|
2011-07-06 04:03:35 +00:00
|
|
|
# define UNICODE_STRING(cs, _length) icu::UnicodeString(cs, _length, US_INV)
|
1999-12-28 23:39:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2002-01-22 00:27:49 +00:00
|
|
|
* Unicode String literals in C++.
|
|
|
|
* Dependent on the platform properties, different UnicodeString
|
|
|
|
* constructors should be used to create a UnicodeString object from
|
|
|
|
* a string literal.
|
|
|
|
* The macros are defined for improved performance.
|
|
|
|
* They work only for strings that contain "invariant characters", i.e.,
|
|
|
|
* only latin letters, digits, and some punctuation.
|
|
|
|
* See utypes.h for details.
|
|
|
|
*
|
|
|
|
* The string parameter must be a C string literal.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2002-01-22 00:27:49 +00:00
|
|
|
*/
|
2007-05-30 22:28:35 +00:00
|
|
|
#define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1)
|
2002-01-22 00:27:49 +00:00
|
|
|
|
2011-07-07 18:46:19 +00:00
|
|
|
/**
|
|
|
|
* \def UNISTR_FROM_CHAR_EXPLICIT
|
|
|
|
* This can be defined to be empty or "explicit".
|
|
|
|
* If explicit, then the UnicodeString(UChar) and UnicodeString(UChar32)
|
|
|
|
* constructors are marked as explicit, preventing their inadvertent use.
|
|
|
|
* @draft ICU 49
|
|
|
|
*/
|
|
|
|
#ifndef UNISTR_FROM_CHAR_EXPLICIT
|
|
|
|
# if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)
|
|
|
|
// Auto-"explicit" in ICU library code.
|
|
|
|
# define UNISTR_FROM_CHAR_EXPLICIT explicit
|
|
|
|
# else
|
|
|
|
// Empty by default for source code compatibility.
|
|
|
|
# define UNISTR_FROM_CHAR_EXPLICIT
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \def UNISTR_FROM_STRING_EXPLICIT
|
|
|
|
* This can be defined to be empty or "explicit".
|
|
|
|
* If explicit, then the UnicodeString(const char *) and UnicodeString(const UChar *)
|
|
|
|
* constructors are marked as explicit, preventing their inadvertent use.
|
|
|
|
*
|
|
|
|
* In particular, this helps prevent accidentally depending on ICU conversion code
|
|
|
|
* by passing a string literal into an API with a const UnicodeString & parameter.
|
|
|
|
* @draft ICU 49
|
|
|
|
*/
|
|
|
|
#ifndef UNISTR_FROM_STRING_EXPLICIT
|
|
|
|
# if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)
|
|
|
|
// Auto-"explicit" in ICU library code.
|
|
|
|
# define UNISTR_FROM_STRING_EXPLICIT explicit
|
|
|
|
# else
|
|
|
|
// Empty by default for source code compatibility.
|
|
|
|
# define UNISTR_FROM_STRING_EXPLICIT
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2002-09-04 00:57:54 +00:00
|
|
|
/**
|
2000-12-15 19:57:12 +00:00
|
|
|
* UnicodeString is a string class that stores Unicode characters directly and provides
|
2002-09-04 00:57:54 +00:00
|
|
|
* similar functionality as the Java String and StringBuffer classes.
|
2000-12-15 19:57:12 +00:00
|
|
|
* It is a concrete implementation of the abstract class Replaceable (for transliteration).
|
2000-03-29 01:13:49 +00:00
|
|
|
*
|
2002-11-07 02:38:51 +00:00
|
|
|
* The UnicodeString class is not suitable for subclassing.
|
|
|
|
*
|
2002-09-04 00:57:54 +00:00
|
|
|
* <p>For an overview of Unicode strings in C and C++ see the
|
2007-06-11 19:14:47 +00:00
|
|
|
* <a href="http://icu-project.org/userguide/strings.html">User Guide Strings chapter</a>.</p>
|
2002-09-04 00:57:54 +00:00
|
|
|
*
|
|
|
|
* <p>In ICU, a Unicode string consists of 16-bit Unicode <em>code units</em>.
|
2005-06-15 04:20:43 +00:00
|
|
|
* A Unicode character may be stored with either one code unit
|
|
|
|
* (the most common case) or with a matched pair of special code units
|
|
|
|
* ("surrogates"). The data type for code units is UChar.
|
2002-09-04 00:57:54 +00:00
|
|
|
* For single-character handling, a Unicode character code <em>point</em> is a value
|
2000-12-15 19:57:12 +00:00
|
|
|
* in the range 0..0x10ffff. ICU uses the UChar32 type for code points.</p>
|
|
|
|
*
|
|
|
|
* <p>Indexes and offsets into and lengths of strings always count code units, not code points.
|
|
|
|
* This is the same as with multi-byte char* strings in traditional string handling.
|
|
|
|
* Operations on partial strings typically do not test for code point boundaries.
|
|
|
|
* If necessary, the user needs to take care of such boundaries by testing for the code unit
|
2001-09-27 22:37:55 +00:00
|
|
|
* values or by using functions like
|
|
|
|
* UnicodeString::getChar32Start() and UnicodeString::getChar32Limit()
|
2002-10-04 22:09:49 +00:00
|
|
|
* (or, in C, the equivalent macros U16_SET_CP_START() and U16_SET_CP_LIMIT(), see utf.h).</p>
|
2000-12-15 19:57:12 +00:00
|
|
|
*
|
2003-04-30 02:41:01 +00:00
|
|
|
* UnicodeString methods are more lenient with regard to input parameter values
|
|
|
|
* than other ICU APIs. In particular:
|
|
|
|
* - If indexes are out of bounds for a UnicodeString object
|
|
|
|
* (<0 or >length()) then they are "pinned" to the nearest boundary.
|
|
|
|
* - If primitive string pointer values (e.g., const UChar * or char *)
|
|
|
|
* for input strings are NULL, then those input string parameters are treated
|
|
|
|
* as if they pointed to an empty string.
|
2003-05-29 23:01:39 +00:00
|
|
|
* However, this is <em>not</em> the case for char * parameters for charset names
|
|
|
|
* or other IDs.
|
2003-04-30 02:41:01 +00:00
|
|
|
* - Most UnicodeString methods do not take a UErrorCode parameter because
|
|
|
|
* there are usually very few opportunities for failure other than a shortage
|
|
|
|
* of memory, error codes in low-level C++ string methods would be inconvenient,
|
|
|
|
* and the error code as the last parameter (ICU convention) would prevent
|
|
|
|
* the use of default parameter values.
|
|
|
|
* Instead, such methods set the UnicodeString into a "bogus" state
|
|
|
|
* (see isBogus()) if an error occurs.
|
|
|
|
*
|
|
|
|
* In string comparisons, two UnicodeString objects that are both "bogus"
|
|
|
|
* compare equal (to be transitive and prevent endless loops in sorting),
|
|
|
|
* and a "bogus" string compares less than any non-"bogus" one.
|
|
|
|
*
|
2003-06-06 19:06:42 +00:00
|
|
|
* Const UnicodeString methods are thread-safe. Multiple threads can use
|
|
|
|
* const methods on the same UnicodeString object simultaneously,
|
|
|
|
* but non-const methods must not be called concurrently (in multiple threads)
|
|
|
|
* with any other (const or non-const) methods.
|
|
|
|
*
|
|
|
|
* Similarly, const UnicodeString & parameters are thread-safe.
|
|
|
|
* One object may be passed in as such a parameter concurrently in multiple threads.
|
|
|
|
* This includes the const UnicodeString & parameters for
|
|
|
|
* copy construction, assignment, and cloning.
|
2003-05-30 00:16:56 +00:00
|
|
|
*
|
2002-09-04 00:57:54 +00:00
|
|
|
* <p>UnicodeString uses several storage methods.
|
|
|
|
* String contents can be stored inside the UnicodeString object itself,
|
|
|
|
* in an allocated and shared buffer, or in an outside buffer that is "aliased".
|
|
|
|
* Most of this is done transparently, but careful aliasing in particular provides
|
|
|
|
* significant performance improvements.
|
|
|
|
* Also, the internal buffer is accessible via special functions.
|
|
|
|
* For details see the
|
2007-06-11 19:14:47 +00:00
|
|
|
* <a href="http://icu-project.org/userguide/strings.html">User Guide Strings chapter</a>.</p>
|
2000-12-15 19:57:12 +00:00
|
|
|
*
|
2002-09-04 00:57:54 +00:00
|
|
|
* @see utf.h
|
|
|
|
* @see CharacterIterator
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2011-02-03 22:07:22 +00:00
|
|
|
class U_COMMON_API UnicodeString : public Replaceable
|
1999-12-28 23:39:02 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2004-08-26 22:58:39 +00:00
|
|
|
/**
|
|
|
|
* Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor
|
|
|
|
* which constructs a Unicode string from an invariant-character char * string.
|
|
|
|
* Use the macro US_INV instead of the full qualification for this value.
|
|
|
|
*
|
|
|
|
* @see US_INV
|
2006-01-18 03:34:19 +00:00
|
|
|
* @stable ICU 3.2
|
2004-08-26 22:58:39 +00:00
|
|
|
*/
|
|
|
|
enum EInvariant {
|
|
|
|
/**
|
|
|
|
* @see EInvariant
|
2006-01-18 03:34:19 +00:00
|
|
|
* @stable ICU 3.2
|
2004-08-26 22:58:39 +00:00
|
|
|
*/
|
|
|
|
kInvariant
|
|
|
|
};
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
//========================================
|
|
|
|
// Read-only operations
|
|
|
|
//========================================
|
2001-01-02 19:37:08 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/* Comparison - bitwise only - for international comparison use collation */
|
2001-01-02 19:37:08 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Equality operator. Performs only bitwise comparison.
|
|
|
|
* @param text The UnicodeString to compare to this one.
|
|
|
|
* @return TRUE if <TT>text</TT> contains the same characters as this one,
|
|
|
|
* FALSE otherwise.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool operator== (const UnicodeString& text) const;
|
2001-01-02 19:37:08 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Inequality operator. Performs only bitwise comparison.
|
|
|
|
* @param text The UnicodeString to compare to this one.
|
|
|
|
* @return FALSE if <TT>text</TT> contains the same characters as this one,
|
|
|
|
* TRUE otherwise.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool operator!= (const UnicodeString& text) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Greater than operator. Performs only bitwise comparison.
|
|
|
|
* @param text The UnicodeString to compare to this one.
|
2004-05-06 15:26:53 +00:00
|
|
|
* @return TRUE if the characters in this are bitwise
|
|
|
|
* greater than the characters in <code>text</code>, FALSE otherwise
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool operator> (const UnicodeString& text) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Less than operator. Performs only bitwise comparison.
|
|
|
|
* @param text The UnicodeString to compare to this one.
|
2004-05-06 15:26:53 +00:00
|
|
|
* @return TRUE if the characters in this are bitwise
|
|
|
|
* less than the characters in <code>text</code>, FALSE otherwise
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool operator< (const UnicodeString& text) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Greater than or equal operator. Performs only bitwise comparison.
|
|
|
|
* @param text The UnicodeString to compare to this one.
|
2004-05-06 15:26:53 +00:00
|
|
|
* @return TRUE if the characters in this are bitwise
|
|
|
|
* greater than or equal to the characters in <code>text</code>, FALSE otherwise
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool operator>= (const UnicodeString& text) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Less than or equal operator. Performs only bitwise comparison.
|
|
|
|
* @param text The UnicodeString to compare to this one.
|
2004-05-06 15:26:53 +00:00
|
|
|
* @return TRUE if the characters in this are bitwise
|
|
|
|
* less than or equal to the characters in <code>text</code>, FALSE otherwise
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool operator<= (const UnicodeString& text) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare the characters bitwise in this UnicodeString to
|
2004-05-06 15:26:53 +00:00
|
|
|
* the characters in <code>text</code>.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param text The UnicodeString to compare to this one.
|
2004-05-06 15:26:53 +00:00
|
|
|
* @return The result of bitwise character comparison: 0 if this
|
2004-08-24 17:21:14 +00:00
|
|
|
* contains the same characters as <code>text</code>, -1 if the characters in
|
2004-05-06 15:26:53 +00:00
|
|
|
* this are bitwise less than the characters in <code>text</code>, +1 if the
|
2004-08-24 17:21:14 +00:00
|
|
|
* characters in this are bitwise greater than the characters
|
2004-05-06 15:26:53 +00:00
|
|
|
* in <code>text</code>.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline int8_t compare(const UnicodeString& text) const;
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Compare the characters bitwise in the range
|
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) with the characters
|
2004-05-06 15:26:53 +00:00
|
|
|
* in <TT>text</TT>
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param start the offset at which the compare operation begins
|
|
|
|
* @param length the number of characters of text to compare.
|
2004-05-25 03:23:31 +00:00
|
|
|
* @param text the other text to be compared against this string.
|
2004-05-06 15:26:53 +00:00
|
|
|
* @return The result of bitwise character comparison: 0 if this
|
2004-08-24 17:21:14 +00:00
|
|
|
* contains the same characters as <code>text</code>, -1 if the characters in
|
2004-05-06 15:26:53 +00:00
|
|
|
* this are bitwise less than the characters in <code>text</code>, +1 if the
|
2004-08-24 17:21:14 +00:00
|
|
|
* characters in this are bitwise greater than the characters
|
2004-05-06 15:26:53 +00:00
|
|
|
* in <code>text</code>.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t compare(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length,
|
2004-05-06 15:26:53 +00:00
|
|
|
const UnicodeString& text) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Compare the characters bitwise in the range
|
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) with the characters
|
|
|
|
* in <TT>srcText</TT> in the range
|
|
|
|
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param start the offset at which the compare operation begins
|
|
|
|
* @param length the number of characters in this to compare.
|
|
|
|
* @param srcText the text to be compared
|
|
|
|
* @param srcStart the offset into <TT>srcText</TT> to start comparison
|
|
|
|
* @param srcLength the number of characters in <TT>src</TT> to compare
|
2004-05-06 15:26:53 +00:00
|
|
|
* @return The result of bitwise character comparison: 0 if this
|
2004-08-24 17:21:14 +00:00
|
|
|
* contains the same characters as <code>srcText</code>, -1 if the characters in
|
2004-05-06 15:26:53 +00:00
|
|
|
* this are bitwise less than the characters in <code>srcText</code>, +1 if the
|
2004-08-24 17:21:14 +00:00
|
|
|
* characters in this are bitwise greater than the characters
|
2004-05-06 15:26:53 +00:00
|
|
|
* in <code>srcText</code>.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t compare(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length,
|
|
|
|
const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength) const;
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Compare the characters bitwise in this UnicodeString with the first
|
1999-12-28 23:39:02 +00:00
|
|
|
* <TT>srcLength</TT> characters in <TT>srcChars</TT>.
|
|
|
|
* @param srcChars The characters to compare to this UnicodeString.
|
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT> to compare
|
2004-05-06 15:26:53 +00:00
|
|
|
* @return The result of bitwise character comparison: 0 if this
|
2004-08-24 17:21:14 +00:00
|
|
|
* contains the same characters as <code>srcChars</code>, -1 if the characters in
|
2004-05-06 15:26:53 +00:00
|
|
|
* this are bitwise less than the characters in <code>srcChars</code>, +1 if the
|
2004-08-24 17:21:14 +00:00
|
|
|
* characters in this are bitwise greater than the characters
|
2004-05-06 15:26:53 +00:00
|
|
|
* in <code>srcChars</code>.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline int8_t compare(const UChar *srcChars,
|
|
|
|
int32_t srcLength) const;
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Compare the characters bitwise in the range
|
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) with the first
|
1999-12-28 23:39:02 +00:00
|
|
|
* <TT>length</TT> characters in <TT>srcChars</TT>
|
|
|
|
* @param start the offset at which the compare operation begins
|
|
|
|
* @param length the number of characters to compare.
|
|
|
|
* @param srcChars the characters to be compared
|
2004-05-06 15:26:53 +00:00
|
|
|
* @return The result of bitwise character comparison: 0 if this
|
2004-08-24 17:21:14 +00:00
|
|
|
* contains the same characters as <code>srcChars</code>, -1 if the characters in
|
2004-05-06 15:26:53 +00:00
|
|
|
* this are bitwise less than the characters in <code>srcChars</code>, +1 if the
|
2004-08-24 17:21:14 +00:00
|
|
|
* characters in this are bitwise greater than the characters
|
2004-05-06 15:26:53 +00:00
|
|
|
* in <code>srcChars</code>.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t compare(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length,
|
|
|
|
const UChar *srcChars) const;
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Compare the characters bitwise in the range
|
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) with the characters
|
|
|
|
* in <TT>srcChars</TT> in the range
|
|
|
|
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param start the offset at which the compare operation begins
|
|
|
|
* @param length the number of characters in this to compare
|
|
|
|
* @param srcChars the characters to be compared
|
|
|
|
* @param srcStart the offset into <TT>srcChars</TT> to start comparison
|
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT> to compare
|
2004-05-06 15:26:53 +00:00
|
|
|
* @return The result of bitwise character comparison: 0 if this
|
2004-08-24 17:21:14 +00:00
|
|
|
* contains the same characters as <code>srcChars</code>, -1 if the characters in
|
2004-05-06 15:26:53 +00:00
|
|
|
* this are bitwise less than the characters in <code>srcChars</code>, +1 if the
|
2004-08-24 17:21:14 +00:00
|
|
|
* characters in this are bitwise greater than the characters
|
2004-05-06 15:26:53 +00:00
|
|
|
* in <code>srcChars</code>.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t compare(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length,
|
|
|
|
const UChar *srcChars,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength) const;
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Compare the characters bitwise in the range
|
|
|
|
* [<TT>start</TT>, <TT>limit</TT>) with the characters
|
|
|
|
* in <TT>srcText</TT> in the range
|
|
|
|
* [<TT>srcStart</TT>, <TT>srcLimit</TT>).
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param start the offset at which the compare operation begins
|
|
|
|
* @param limit the offset immediately following the compare operation
|
|
|
|
* @param srcText the text to be compared
|
|
|
|
* @param srcStart the offset into <TT>srcText</TT> to start comparison
|
|
|
|
* @param srcLimit the offset into <TT>srcText</TT> to limit comparison
|
2004-05-06 15:26:53 +00:00
|
|
|
* @return The result of bitwise character comparison: 0 if this
|
2004-08-24 17:21:14 +00:00
|
|
|
* contains the same characters as <code>srcText</code>, -1 if the characters in
|
2004-05-06 15:26:53 +00:00
|
|
|
* this are bitwise less than the characters in <code>srcText</code>, +1 if the
|
2004-08-24 17:21:14 +00:00
|
|
|
* characters in this are bitwise greater than the characters
|
2004-05-06 15:26:53 +00:00
|
|
|
* in <code>srcText</code>.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t compareBetween(int32_t start,
|
|
|
|
int32_t limit,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
|
|
|
int32_t srcLimit) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2001-01-24 02:37:58 +00:00
|
|
|
/**
|
|
|
|
* Compare two Unicode strings in code point order.
|
2007-08-24 19:27:03 +00:00
|
|
|
* The result may be different from the results of compare(), operator<, etc.
|
2001-01-24 02:37:58 +00:00
|
|
|
* if supplementary characters are present:
|
|
|
|
*
|
|
|
|
* In UTF-16, supplementary characters (with code points U+10000 and above) are
|
|
|
|
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
|
|
|
* which means that they compare as less than some other BMP characters like U+feff.
|
|
|
|
* This function compares Unicode strings in code point order.
|
|
|
|
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
|
|
*
|
|
|
|
* @param text Another string to compare this one to.
|
|
|
|
* @return a negative/zero/positive integer corresponding to whether
|
|
|
|
* this string is less than/equal to/greater than the second one
|
|
|
|
* in code point order
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-01-24 02:37:58 +00:00
|
|
|
*/
|
|
|
|
inline int8_t compareCodePointOrder(const UnicodeString& text) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare two Unicode strings in code point order.
|
2007-08-24 19:27:03 +00:00
|
|
|
* The result may be different from the results of compare(), operator<, etc.
|
2001-01-24 02:37:58 +00:00
|
|
|
* if supplementary characters are present:
|
|
|
|
*
|
|
|
|
* In UTF-16, supplementary characters (with code points U+10000 and above) are
|
|
|
|
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
|
|
|
* which means that they compare as less than some other BMP characters like U+feff.
|
|
|
|
* This function compares Unicode strings in code point order.
|
|
|
|
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
|
|
*
|
|
|
|
* @param start The start offset in this string at which the compare operation begins.
|
|
|
|
* @param length The number of code units from this string to compare.
|
|
|
|
* @param srcText Another string to compare this one to.
|
|
|
|
* @return a negative/zero/positive integer corresponding to whether
|
|
|
|
* this string is less than/equal to/greater than the second one
|
|
|
|
* in code point order
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-01-24 02:37:58 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t compareCodePointOrder(int32_t start,
|
2001-01-24 02:37:58 +00:00
|
|
|
int32_t length,
|
|
|
|
const UnicodeString& srcText) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare two Unicode strings in code point order.
|
2007-08-24 19:27:03 +00:00
|
|
|
* The result may be different from the results of compare(), operator<, etc.
|
2001-01-24 02:37:58 +00:00
|
|
|
* if supplementary characters are present:
|
|
|
|
*
|
|
|
|
* In UTF-16, supplementary characters (with code points U+10000 and above) are
|
|
|
|
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
|
|
|
* which means that they compare as less than some other BMP characters like U+feff.
|
|
|
|
* This function compares Unicode strings in code point order.
|
|
|
|
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
|
|
*
|
|
|
|
* @param start The start offset in this string at which the compare operation begins.
|
|
|
|
* @param length The number of code units from this string to compare.
|
|
|
|
* @param srcText Another string to compare this one to.
|
|
|
|
* @param srcStart The start offset in that string at which the compare operation begins.
|
|
|
|
* @param srcLength The number of code units from that string to compare.
|
|
|
|
* @return a negative/zero/positive integer corresponding to whether
|
|
|
|
* this string is less than/equal to/greater than the second one
|
|
|
|
* in code point order
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-01-24 02:37:58 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t compareCodePointOrder(int32_t start,
|
2001-01-24 02:37:58 +00:00
|
|
|
int32_t length,
|
|
|
|
const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2001-01-24 02:37:58 +00:00
|
|
|
int32_t srcLength) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare two Unicode strings in code point order.
|
2007-08-24 19:27:03 +00:00
|
|
|
* The result may be different from the results of compare(), operator<, etc.
|
2001-01-24 02:37:58 +00:00
|
|
|
* if supplementary characters are present:
|
|
|
|
*
|
|
|
|
* In UTF-16, supplementary characters (with code points U+10000 and above) are
|
|
|
|
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
|
|
|
* which means that they compare as less than some other BMP characters like U+feff.
|
|
|
|
* This function compares Unicode strings in code point order.
|
|
|
|
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
|
|
*
|
|
|
|
* @param srcChars A pointer to another string to compare this one to.
|
|
|
|
* @param srcLength The number of code units from that string to compare.
|
|
|
|
* @return a negative/zero/positive integer corresponding to whether
|
|
|
|
* this string is less than/equal to/greater than the second one
|
|
|
|
* in code point order
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-01-24 02:37:58 +00:00
|
|
|
*/
|
|
|
|
inline int8_t compareCodePointOrder(const UChar *srcChars,
|
|
|
|
int32_t srcLength) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare two Unicode strings in code point order.
|
2007-08-24 19:27:03 +00:00
|
|
|
* The result may be different from the results of compare(), operator<, etc.
|
2001-01-24 02:37:58 +00:00
|
|
|
* if supplementary characters are present:
|
|
|
|
*
|
|
|
|
* In UTF-16, supplementary characters (with code points U+10000 and above) are
|
|
|
|
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
|
|
|
* which means that they compare as less than some other BMP characters like U+feff.
|
|
|
|
* This function compares Unicode strings in code point order.
|
|
|
|
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
|
|
*
|
|
|
|
* @param start The start offset in this string at which the compare operation begins.
|
|
|
|
* @param length The number of code units from this string to compare.
|
|
|
|
* @param srcChars A pointer to another string to compare this one to.
|
|
|
|
* @return a negative/zero/positive integer corresponding to whether
|
|
|
|
* this string is less than/equal to/greater than the second one
|
|
|
|
* in code point order
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-01-24 02:37:58 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t compareCodePointOrder(int32_t start,
|
2001-01-24 02:37:58 +00:00
|
|
|
int32_t length,
|
|
|
|
const UChar *srcChars) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare two Unicode strings in code point order.
|
2007-08-24 19:27:03 +00:00
|
|
|
* The result may be different from the results of compare(), operator<, etc.
|
2001-01-24 02:37:58 +00:00
|
|
|
* if supplementary characters are present:
|
|
|
|
*
|
|
|
|
* In UTF-16, supplementary characters (with code points U+10000 and above) are
|
|
|
|
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
|
|
|
* which means that they compare as less than some other BMP characters like U+feff.
|
|
|
|
* This function compares Unicode strings in code point order.
|
|
|
|
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
|
|
*
|
|
|
|
* @param start The start offset in this string at which the compare operation begins.
|
|
|
|
* @param length The number of code units from this string to compare.
|
|
|
|
* @param srcChars A pointer to another string to compare this one to.
|
|
|
|
* @param srcStart The start offset in that string at which the compare operation begins.
|
|
|
|
* @param srcLength The number of code units from that string to compare.
|
|
|
|
* @return a negative/zero/positive integer corresponding to whether
|
|
|
|
* this string is less than/equal to/greater than the second one
|
|
|
|
* in code point order
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-01-24 02:37:58 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t compareCodePointOrder(int32_t start,
|
2001-01-24 02:37:58 +00:00
|
|
|
int32_t length,
|
|
|
|
const UChar *srcChars,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2001-01-24 02:37:58 +00:00
|
|
|
int32_t srcLength) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare two Unicode strings in code point order.
|
2007-08-24 19:27:03 +00:00
|
|
|
* The result may be different from the results of compare(), operator<, etc.
|
2001-01-24 02:37:58 +00:00
|
|
|
* if supplementary characters are present:
|
|
|
|
*
|
|
|
|
* In UTF-16, supplementary characters (with code points U+10000 and above) are
|
|
|
|
* stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
|
|
|
|
* which means that they compare as less than some other BMP characters like U+feff.
|
|
|
|
* This function compares Unicode strings in code point order.
|
|
|
|
* If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
|
|
|
|
*
|
|
|
|
* @param start The start offset in this string at which the compare operation begins.
|
|
|
|
* @param limit The offset after the last code unit from this string to compare.
|
|
|
|
* @param srcText Another string to compare this one to.
|
|
|
|
* @param srcStart The start offset in that string at which the compare operation begins.
|
|
|
|
* @param srcLimit The offset after the last code unit from that string to compare.
|
|
|
|
* @return a negative/zero/positive integer corresponding to whether
|
|
|
|
* this string is less than/equal to/greater than the second one
|
|
|
|
* in code point order
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-01-24 02:37:58 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t compareCodePointOrderBetween(int32_t start,
|
|
|
|
int32_t limit,
|
2001-01-24 02:37:58 +00:00
|
|
|
const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
|
|
|
int32_t srcLimit) const;
|
2001-01-24 02:37:58 +00:00
|
|
|
|
2001-02-14 01:10:10 +00:00
|
|
|
/**
|
|
|
|
* Compare two strings case-insensitively using full case folding.
|
|
|
|
* This is equivalent to this->foldCase(options).compare(text.foldCase(options)).
|
|
|
|
*
|
|
|
|
* @param text Another string to compare this one to.
|
2002-05-24 17:05:31 +00:00
|
|
|
* @param options A bit set of options:
|
|
|
|
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
|
|
|
* Comparison in code unit order with default case folding.
|
|
|
|
*
|
|
|
|
* - U_COMPARE_CODE_POINT_ORDER
|
|
|
|
* Set to choose code point order instead of code unit order
|
|
|
|
* (see u_strCompare for details).
|
|
|
|
*
|
|
|
|
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
|
|
|
*
|
2001-02-14 01:10:10 +00:00
|
|
|
* @return A negative, zero, or positive integer indicating the comparison result.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-02-14 01:10:10 +00:00
|
|
|
*/
|
|
|
|
inline int8_t caseCompare(const UnicodeString& text, uint32_t options) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare two strings case-insensitively using full case folding.
|
|
|
|
* This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).
|
|
|
|
*
|
|
|
|
* @param start The start offset in this string at which the compare operation begins.
|
|
|
|
* @param length The number of code units from this string to compare.
|
|
|
|
* @param srcText Another string to compare this one to.
|
2002-05-24 17:05:31 +00:00
|
|
|
* @param options A bit set of options:
|
|
|
|
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
|
|
|
* Comparison in code unit order with default case folding.
|
|
|
|
*
|
|
|
|
* - U_COMPARE_CODE_POINT_ORDER
|
|
|
|
* Set to choose code point order instead of code unit order
|
|
|
|
* (see u_strCompare for details).
|
|
|
|
*
|
|
|
|
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
|
|
|
*
|
2001-02-14 01:10:10 +00:00
|
|
|
* @return A negative, zero, or positive integer indicating the comparison result.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-02-14 01:10:10 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t caseCompare(int32_t start,
|
2001-02-14 01:10:10 +00:00
|
|
|
int32_t length,
|
|
|
|
const UnicodeString& srcText,
|
|
|
|
uint32_t options) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare two strings case-insensitively using full case folding.
|
|
|
|
* This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).
|
|
|
|
*
|
|
|
|
* @param start The start offset in this string at which the compare operation begins.
|
|
|
|
* @param length The number of code units from this string to compare.
|
|
|
|
* @param srcText Another string to compare this one to.
|
|
|
|
* @param srcStart The start offset in that string at which the compare operation begins.
|
|
|
|
* @param srcLength The number of code units from that string to compare.
|
2002-05-24 17:05:31 +00:00
|
|
|
* @param options A bit set of options:
|
|
|
|
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
|
|
|
* Comparison in code unit order with default case folding.
|
|
|
|
*
|
|
|
|
* - U_COMPARE_CODE_POINT_ORDER
|
|
|
|
* Set to choose code point order instead of code unit order
|
|
|
|
* (see u_strCompare for details).
|
|
|
|
*
|
|
|
|
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
|
|
|
*
|
2001-02-14 01:10:10 +00:00
|
|
|
* @return A negative, zero, or positive integer indicating the comparison result.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-02-14 01:10:10 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t caseCompare(int32_t start,
|
2001-02-14 01:10:10 +00:00
|
|
|
int32_t length,
|
|
|
|
const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2001-02-14 01:10:10 +00:00
|
|
|
int32_t srcLength,
|
|
|
|
uint32_t options) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare two strings case-insensitively using full case folding.
|
|
|
|
* This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
|
|
|
|
*
|
|
|
|
* @param srcChars A pointer to another string to compare this one to.
|
|
|
|
* @param srcLength The number of code units from that string to compare.
|
2002-05-24 17:05:31 +00:00
|
|
|
* @param options A bit set of options:
|
|
|
|
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
|
|
|
* Comparison in code unit order with default case folding.
|
|
|
|
*
|
|
|
|
* - U_COMPARE_CODE_POINT_ORDER
|
|
|
|
* Set to choose code point order instead of code unit order
|
|
|
|
* (see u_strCompare for details).
|
|
|
|
*
|
|
|
|
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
|
|
|
*
|
2001-02-14 01:10:10 +00:00
|
|
|
* @return A negative, zero, or positive integer indicating the comparison result.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-02-14 01:10:10 +00:00
|
|
|
*/
|
|
|
|
inline int8_t caseCompare(const UChar *srcChars,
|
|
|
|
int32_t srcLength,
|
|
|
|
uint32_t options) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare two strings case-insensitively using full case folding.
|
|
|
|
* This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
|
|
|
|
*
|
|
|
|
* @param start The start offset in this string at which the compare operation begins.
|
|
|
|
* @param length The number of code units from this string to compare.
|
|
|
|
* @param srcChars A pointer to another string to compare this one to.
|
2002-05-24 17:05:31 +00:00
|
|
|
* @param options A bit set of options:
|
|
|
|
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
|
|
|
* Comparison in code unit order with default case folding.
|
|
|
|
*
|
|
|
|
* - U_COMPARE_CODE_POINT_ORDER
|
|
|
|
* Set to choose code point order instead of code unit order
|
|
|
|
* (see u_strCompare for details).
|
|
|
|
*
|
|
|
|
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
|
|
|
*
|
2001-02-14 01:10:10 +00:00
|
|
|
* @return A negative, zero, or positive integer indicating the comparison result.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-02-14 01:10:10 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t caseCompare(int32_t start,
|
2001-02-14 01:10:10 +00:00
|
|
|
int32_t length,
|
|
|
|
const UChar *srcChars,
|
|
|
|
uint32_t options) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare two strings case-insensitively using full case folding.
|
|
|
|
* This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
|
|
|
|
*
|
|
|
|
* @param start The start offset in this string at which the compare operation begins.
|
|
|
|
* @param length The number of code units from this string to compare.
|
|
|
|
* @param srcChars A pointer to another string to compare this one to.
|
|
|
|
* @param srcStart The start offset in that string at which the compare operation begins.
|
|
|
|
* @param srcLength The number of code units from that string to compare.
|
2002-05-24 17:05:31 +00:00
|
|
|
* @param options A bit set of options:
|
|
|
|
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
|
|
|
* Comparison in code unit order with default case folding.
|
|
|
|
*
|
|
|
|
* - U_COMPARE_CODE_POINT_ORDER
|
|
|
|
* Set to choose code point order instead of code unit order
|
|
|
|
* (see u_strCompare for details).
|
|
|
|
*
|
|
|
|
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
|
|
|
*
|
2001-02-14 01:10:10 +00:00
|
|
|
* @return A negative, zero, or positive integer indicating the comparison result.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-02-14 01:10:10 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t caseCompare(int32_t start,
|
2001-02-14 01:10:10 +00:00
|
|
|
int32_t length,
|
|
|
|
const UChar *srcChars,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2001-02-14 01:10:10 +00:00
|
|
|
int32_t srcLength,
|
|
|
|
uint32_t options) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare two strings case-insensitively using full case folding.
|
|
|
|
* This is equivalent to this->foldCase(options).compareBetween(text.foldCase(options)).
|
|
|
|
*
|
|
|
|
* @param start The start offset in this string at which the compare operation begins.
|
|
|
|
* @param limit The offset after the last code unit from this string to compare.
|
|
|
|
* @param srcText Another string to compare this one to.
|
|
|
|
* @param srcStart The start offset in that string at which the compare operation begins.
|
|
|
|
* @param srcLimit The offset after the last code unit from that string to compare.
|
2002-05-24 17:05:31 +00:00
|
|
|
* @param options A bit set of options:
|
|
|
|
* - U_FOLD_CASE_DEFAULT or 0 is used for default options:
|
|
|
|
* Comparison in code unit order with default case folding.
|
|
|
|
*
|
|
|
|
* - U_COMPARE_CODE_POINT_ORDER
|
|
|
|
* Set to choose code point order instead of code unit order
|
|
|
|
* (see u_strCompare for details).
|
|
|
|
*
|
|
|
|
* - U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
|
|
|
*
|
2001-02-14 01:10:10 +00:00
|
|
|
* @return A negative, zero, or positive integer indicating the comparison result.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-02-14 01:10:10 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int8_t caseCompareBetween(int32_t start,
|
|
|
|
int32_t limit,
|
2001-02-14 01:10:10 +00:00
|
|
|
const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
|
|
|
int32_t srcLimit,
|
2001-02-14 01:10:10 +00:00
|
|
|
uint32_t options) const;
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Determine if this starts with the characters in <TT>text</TT>
|
|
|
|
* @param text The text to match.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return TRUE if this starts with the characters in <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* FALSE otherwise
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool startsWith(const UnicodeString& text) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Determine if this starts with the characters in <TT>srcText</TT>
|
|
|
|
* in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param srcText The text to match.
|
|
|
|
* @param srcStart the offset into <TT>srcText</TT> to start matching
|
|
|
|
* @param srcLength the number of characters in <TT>srcText</TT> to match
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return TRUE if this starts with the characters in <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* FALSE otherwise
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool startsWith(const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength) const;
|
2001-01-02 19:37:08 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Determine if this starts with the characters in <TT>srcChars</TT>
|
|
|
|
* @param srcChars The characters to match.
|
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT>
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return TRUE if this starts with the characters in <TT>srcChars</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* FALSE otherwise
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool startsWith(const UChar *srcChars,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength) const;
|
2001-01-02 19:37:08 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Determine if this ends with the characters in <TT>srcChars</TT>
|
|
|
|
* in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param srcChars The characters to match.
|
|
|
|
* @param srcStart the offset into <TT>srcText</TT> to start matching
|
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT> to match
|
2001-11-13 22:47:47 +00:00
|
|
|
* @return TRUE if this ends with the characters in <TT>srcChars</TT>, FALSE otherwise
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-11-13 22:47:47 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool startsWith(const UChar *srcChars,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if this ends with the characters in <TT>text</TT>
|
|
|
|
* @param text The text to match.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return TRUE if this ends with the characters in <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* FALSE otherwise
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool endsWith(const UnicodeString& text) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Determine if this ends with the characters in <TT>srcText</TT>
|
|
|
|
* in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param srcText The text to match.
|
|
|
|
* @param srcStart the offset into <TT>srcText</TT> to start matching
|
|
|
|
* @param srcLength the number of characters in <TT>srcText</TT> to match
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return TRUE if this ends with the characters in <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* FALSE otherwise
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool endsWith(const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if this ends with the characters in <TT>srcChars</TT>
|
|
|
|
* @param srcChars The characters to match.
|
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT>
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return TRUE if this ends with the characters in <TT>srcChars</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* FALSE otherwise
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool endsWith(const UChar *srcChars,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength) const;
|
2001-01-02 19:37:08 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Determine if this ends with the characters in <TT>srcChars</TT>
|
|
|
|
* in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param srcChars The characters to match.
|
|
|
|
* @param srcStart the offset into <TT>srcText</TT> to start matching
|
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT> to match
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return TRUE if this ends with the characters in <TT>srcChars</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* FALSE otherwise
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool endsWith(const UChar *srcChars,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength) const;
|
|
|
|
|
2001-01-02 19:37:08 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/* Searching - bitwise only */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Locate in this the first occurrence of the characters in <TT>text</TT>,
|
|
|
|
* using bitwise comparison.
|
|
|
|
* @param text The text to search for.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t indexOf(const UnicodeString& text) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Locate in this the first occurrence of the characters in <TT>text</TT>
|
|
|
|
* starting at offset <TT>start</TT>, using bitwise comparison.
|
|
|
|
* @param text The text to search for.
|
|
|
|
* @param start The offset at which searching will start.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t indexOf(const UnicodeString& text,
|
|
|
|
int32_t start) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Locate in this the first occurrence in the range
|
2004-08-24 17:21:14 +00:00
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) of the characters
|
1999-12-28 23:39:02 +00:00
|
|
|
* in <TT>text</TT>, using bitwise comparison.
|
|
|
|
* @param text The text to search for.
|
|
|
|
* @param start The offset at which searching will start.
|
|
|
|
* @param length The number of characters to search
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t indexOf(const UnicodeString& text,
|
|
|
|
int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Locate in this the first occurrence in the range
|
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) of the characters
|
2004-08-24 17:21:14 +00:00
|
|
|
* in <TT>srcText</TT> in the range
|
|
|
|
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
|
|
|
|
* using bitwise comparison.
|
2003-04-26 00:12:33 +00:00
|
|
|
* @param srcText The text to search for.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param srcStart the offset into <TT>srcText</TT> at which
|
|
|
|
* to start matching
|
|
|
|
* @param srcLength the number of characters in <TT>srcText</TT> to match
|
|
|
|
* @param start the offset into this at which to start matching
|
|
|
|
* @param length the number of characters in this to search
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t indexOf(const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Locate in this the first occurrence of the characters in
|
2004-08-24 17:21:14 +00:00
|
|
|
* <TT>srcChars</TT>
|
|
|
|
* starting at offset <TT>start</TT>, using bitwise comparison.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param srcChars The text to search for.
|
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT> to match
|
|
|
|
* @param start the offset into this at which to start matching
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t indexOf(const UChar *srcChars,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Locate in this the first occurrence in the range
|
2004-08-24 17:21:14 +00:00
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) of the characters
|
1999-12-28 23:39:02 +00:00
|
|
|
* in <TT>srcChars</TT>, using bitwise comparison.
|
2003-04-26 00:12:33 +00:00
|
|
|
* @param srcChars The text to search for.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT>
|
|
|
|
* @param start The offset at which searching will start.
|
|
|
|
* @param length The number of characters to search
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>srcChars</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t indexOf(const UChar *srcChars,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length) const;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Locate in this the first occurrence in the range
|
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) of the characters
|
|
|
|
* in <TT>srcChars</TT> in the range
|
|
|
|
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
|
|
|
|
* using bitwise comparison.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param srcChars The text to search for.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcStart the offset into <TT>srcChars</TT> at which
|
1999-12-28 23:39:02 +00:00
|
|
|
* to start matching
|
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT> to match
|
|
|
|
* @param start the offset into this at which to start matching
|
|
|
|
* @param length the number of characters in this to search
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t indexOf(const UChar *srcChars,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
|
|
|
/**
|
2002-10-24 01:49:58 +00:00
|
|
|
* Locate in this the first occurrence of the BMP code point <code>c</code>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* using bitwise comparison.
|
2000-04-03 23:53:59 +00:00
|
|
|
* @param c The code unit to search for.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return The offset into this of <TT>c</TT>, or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t indexOf(UChar c) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Locate in this the first occurrence of the code point <TT>c</TT>,
|
2000-04-03 23:53:59 +00:00
|
|
|
* using bitwise comparison.
|
2002-02-22 02:00:42 +00:00
|
|
|
*
|
2000-04-03 23:53:59 +00:00
|
|
|
* @param c The code point to search for.
|
|
|
|
* @return The offset into this of <TT>c</TT>, or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-04-03 23:53:59 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t indexOf(UChar32 c) const;
|
2000-04-03 23:53:59 +00:00
|
|
|
|
|
|
|
/**
|
2002-10-24 01:49:58 +00:00
|
|
|
* Locate in this the first occurrence of the BMP code point <code>c</code>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* starting at offset <TT>start</TT>, using bitwise comparison.
|
2000-04-03 23:53:59 +00:00
|
|
|
* @param c The code unit to search for.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param start The offset at which searching will start.
|
|
|
|
* @return The offset into this of <TT>c</TT>, or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t indexOf(UChar c,
|
|
|
|
int32_t start) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-04-03 23:53:59 +00:00
|
|
|
* Locate in this the first occurrence of the code point <TT>c</TT>
|
|
|
|
* starting at offset <TT>start</TT>, using bitwise comparison.
|
2002-02-22 02:00:42 +00:00
|
|
|
*
|
2000-04-03 23:53:59 +00:00
|
|
|
* @param c The code point to search for.
|
|
|
|
* @param start The offset at which searching will start.
|
|
|
|
* @return The offset into this of <TT>c</TT>, or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-04-03 23:53:59 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t indexOf(UChar32 c,
|
|
|
|
int32_t start) const;
|
2000-04-03 23:53:59 +00:00
|
|
|
|
|
|
|
/**
|
2002-10-24 01:49:58 +00:00
|
|
|
* Locate in this the first occurrence of the BMP code point <code>c</code>
|
2004-08-24 17:21:14 +00:00
|
|
|
* in the range [<TT>start</TT>, <TT>start + length</TT>),
|
|
|
|
* using bitwise comparison.
|
2000-04-03 23:53:59 +00:00
|
|
|
* @param c The code unit to search for.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param start the offset into this at which to start matching
|
|
|
|
* @param length the number of characters in this to search
|
|
|
|
* @return The offset into this of <TT>c</TT>, or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t indexOf(UChar c,
|
|
|
|
int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
2000-04-03 23:53:59 +00:00
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Locate in this the first occurrence of the code point <TT>c</TT>
|
|
|
|
* in the range [<TT>start</TT>, <TT>start + length</TT>),
|
|
|
|
* using bitwise comparison.
|
2002-02-22 02:00:42 +00:00
|
|
|
*
|
2000-04-03 23:53:59 +00:00
|
|
|
* @param c The code point to search for.
|
|
|
|
* @param start the offset into this at which to start matching
|
|
|
|
* @param length the number of characters in this to search
|
|
|
|
* @return The offset into this of <TT>c</TT>, or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-04-03 23:53:59 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t indexOf(UChar32 c,
|
|
|
|
int32_t start,
|
2000-04-03 23:53:59 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Locate in this the last occurrence of the characters in <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* using bitwise comparison.
|
|
|
|
* @param text The text to search for.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t lastIndexOf(const UnicodeString& text) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Locate in this the last occurrence of the characters in <TT>text</TT>
|
|
|
|
* starting at offset <TT>start</TT>, using bitwise comparison.
|
|
|
|
* @param text The text to search for.
|
|
|
|
* @param start The offset at which searching will start.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t lastIndexOf(const UnicodeString& text,
|
|
|
|
int32_t start) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Locate in this the last occurrence in the range
|
1999-12-28 23:39:02 +00:00
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) of the characters
|
|
|
|
* in <TT>text</TT>, using bitwise comparison.
|
|
|
|
* @param text The text to search for.
|
|
|
|
* @param start The offset at which searching will start.
|
|
|
|
* @param length The number of characters to search
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t lastIndexOf(const UnicodeString& text,
|
|
|
|
int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Locate in this the last occurrence in the range
|
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) of the characters
|
|
|
|
* in <TT>srcText</TT> in the range
|
|
|
|
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
|
|
|
|
* using bitwise comparison.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param srcText The text to search for.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcStart the offset into <TT>srcText</TT> at which
|
1999-12-28 23:39:02 +00:00
|
|
|
* to start matching
|
|
|
|
* @param srcLength the number of characters in <TT>srcText</TT> to match
|
|
|
|
* @param start the offset into this at which to start matching
|
|
|
|
* @param length the number of characters in this to search
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t lastIndexOf(const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Locate in this the last occurrence of the characters in <TT>srcChars</TT>
|
|
|
|
* starting at offset <TT>start</TT>, using bitwise comparison.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param srcChars The text to search for.
|
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT> to match
|
|
|
|
* @param start the offset into this at which to start matching
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t lastIndexOf(const UChar *srcChars,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Locate in this the last occurrence in the range
|
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) of the characters
|
1999-12-28 23:39:02 +00:00
|
|
|
* in <TT>srcChars</TT>, using bitwise comparison.
|
2003-04-26 00:12:33 +00:00
|
|
|
* @param srcChars The text to search for.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT>
|
|
|
|
* @param start The offset at which searching will start.
|
|
|
|
* @param length The number of characters to search
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>srcChars</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t lastIndexOf(const UChar *srcChars,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length) const;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Locate in this the last occurrence in the range
|
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) of the characters
|
|
|
|
* in <TT>srcChars</TT> in the range
|
|
|
|
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
|
|
|
|
* using bitwise comparison.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param srcChars The text to search for.
|
|
|
|
* @param srcStart the offset into <TT>srcChars</TT> at which
|
|
|
|
* to start matching
|
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT> to match
|
|
|
|
* @param start the offset into this at which to start matching
|
|
|
|
* @param length the number of characters in this to search
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return The offset into this of the start of <TT>text</TT>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t lastIndexOf(const UChar *srcChars,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
|
|
|
/**
|
2002-10-24 01:49:58 +00:00
|
|
|
* Locate in this the last occurrence of the BMP code point <code>c</code>,
|
1999-12-28 23:39:02 +00:00
|
|
|
* using bitwise comparison.
|
2000-04-03 23:53:59 +00:00
|
|
|
* @param c The code unit to search for.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return The offset into this of <TT>c</TT>, or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t lastIndexOf(UChar c) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Locate in this the last occurrence of the code point <TT>c</TT>,
|
2000-04-03 23:53:59 +00:00
|
|
|
* using bitwise comparison.
|
2002-02-22 02:00:42 +00:00
|
|
|
*
|
2000-04-03 23:53:59 +00:00
|
|
|
* @param c The code point to search for.
|
|
|
|
* @return The offset into this of <TT>c</TT>, or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-04-03 23:53:59 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t lastIndexOf(UChar32 c) const;
|
2000-04-03 23:53:59 +00:00
|
|
|
|
|
|
|
/**
|
2002-10-24 01:49:58 +00:00
|
|
|
* Locate in this the last occurrence of the BMP code point <code>c</code>
|
1999-12-28 23:39:02 +00:00
|
|
|
* starting at offset <TT>start</TT>, using bitwise comparison.
|
2000-04-03 23:53:59 +00:00
|
|
|
* @param c The code unit to search for.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param start The offset at which searching will start.
|
|
|
|
* @return The offset into this of <TT>c</TT>, or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t lastIndexOf(UChar c,
|
|
|
|
int32_t start) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-04-03 23:53:59 +00:00
|
|
|
* Locate in this the last occurrence of the code point <TT>c</TT>
|
|
|
|
* starting at offset <TT>start</TT>, using bitwise comparison.
|
2002-02-22 02:00:42 +00:00
|
|
|
*
|
2000-04-03 23:53:59 +00:00
|
|
|
* @param c The code point to search for.
|
|
|
|
* @param start The offset at which searching will start.
|
|
|
|
* @return The offset into this of <TT>c</TT>, or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-04-03 23:53:59 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t lastIndexOf(UChar32 c,
|
|
|
|
int32_t start) const;
|
2000-04-03 23:53:59 +00:00
|
|
|
|
|
|
|
/**
|
2002-10-24 01:49:58 +00:00
|
|
|
* Locate in this the last occurrence of the BMP code point <code>c</code>
|
2004-08-24 17:21:14 +00:00
|
|
|
* in the range [<TT>start</TT>, <TT>start + length</TT>),
|
|
|
|
* using bitwise comparison.
|
2000-04-03 23:53:59 +00:00
|
|
|
* @param c The code unit to search for.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param start the offset into this at which to start matching
|
|
|
|
* @param length the number of characters in this to search
|
|
|
|
* @return The offset into this of <TT>c</TT>, or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t lastIndexOf(UChar c,
|
|
|
|
int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
2000-04-03 23:53:59 +00:00
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Locate in this the last occurrence of the code point <TT>c</TT>
|
|
|
|
* in the range [<TT>start</TT>, <TT>start + length</TT>),
|
|
|
|
* using bitwise comparison.
|
2002-02-22 02:00:42 +00:00
|
|
|
*
|
2000-04-03 23:53:59 +00:00
|
|
|
* @param c The code point to search for.
|
|
|
|
* @param start the offset into this at which to start matching
|
|
|
|
* @param length the number of characters in this to search
|
|
|
|
* @return The offset into this of <TT>c</TT>, or -1 if not found.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-04-03 23:53:59 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t lastIndexOf(UChar32 c,
|
|
|
|
int32_t start,
|
2000-04-03 23:53:59 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/* Character access */
|
|
|
|
|
|
|
|
/**
|
2000-04-01 00:21:57 +00:00
|
|
|
* Return the code unit at offset <tt>offset</tt>.
|
2002-10-24 18:30:07 +00:00
|
|
|
* If the offset is not valid (0..length()-1) then U+ffff is returned.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param offset a valid offset into the text
|
2002-10-24 18:30:07 +00:00
|
|
|
* @return the code unit at offset <tt>offset</tt>
|
|
|
|
* or 0xffff if the offset is not valid for this string
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline UChar charAt(int32_t offset) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-04-01 00:21:57 +00:00
|
|
|
* Return the code unit at offset <tt>offset</tt>.
|
2002-10-24 18:30:07 +00:00
|
|
|
* If the offset is not valid (0..length()-1) then U+ffff is returned.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param offset a valid offset into the text
|
2002-10-24 18:30:07 +00:00
|
|
|
* @return the code unit at offset <tt>offset</tt>
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-10-08 23:56:15 +00:00
|
|
|
inline UChar operator[] (int32_t offset) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-04-01 00:21:57 +00:00
|
|
|
/**
|
|
|
|
* Return the code point that contains the code unit
|
|
|
|
* at offset <tt>offset</tt>.
|
2002-10-24 18:30:07 +00:00
|
|
|
* If the offset is not valid (0..length()-1) then U+ffff is returned.
|
2000-04-01 00:21:57 +00:00
|
|
|
* @param offset a valid offset into the text
|
|
|
|
* that indicates the text offset of any of the code units
|
|
|
|
* that will be assembled into a code point (21-bit value) and returned
|
2002-10-24 18:30:07 +00:00
|
|
|
* @return the code point of text at <tt>offset</tt>
|
|
|
|
* or 0xffff if the offset is not valid for this string
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-04-01 00:21:57 +00:00
|
|
|
*/
|
2011-07-27 05:53:56 +00:00
|
|
|
UChar32 char32At(int32_t offset) const;
|
2000-04-01 00:21:57 +00:00
|
|
|
|
2000-04-03 23:53:59 +00:00
|
|
|
/**
|
|
|
|
* Adjust a random-access offset so that
|
|
|
|
* it points to the beginning of a Unicode character.
|
|
|
|
* The offset that is passed in points to
|
|
|
|
* any code unit of a code point,
|
|
|
|
* while the returned offset will point to the first code unit
|
|
|
|
* of the same code point.
|
|
|
|
* In UTF-16, if the input offset points to a second surrogate
|
|
|
|
* of a surrogate pair, then the returned offset will point
|
|
|
|
* to the first surrogate.
|
|
|
|
* @param offset a valid offset into one code point of the text
|
|
|
|
* @return offset of the first code unit of the same code point
|
2002-10-04 22:09:49 +00:00
|
|
|
* @see U16_SET_CP_START
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-09-27 22:37:55 +00:00
|
|
|
*/
|
2011-07-27 05:53:56 +00:00
|
|
|
int32_t getChar32Start(int32_t offset) const;
|
2001-09-27 22:37:55 +00:00
|
|
|
|
2002-11-13 22:36:43 +00:00
|
|
|
/**
|
|
|
|
* Adjust a random-access offset so that
|
|
|
|
* it points behind a Unicode character.
|
|
|
|
* The offset that is passed in points behind
|
|
|
|
* any code unit of a code point,
|
|
|
|
* while the returned offset will point behind the last code unit
|
|
|
|
* of the same code point.
|
|
|
|
* In UTF-16, if the input offset points behind the first surrogate
|
|
|
|
* (i.e., to the second surrogate)
|
|
|
|
* of a surrogate pair, then the returned offset will point
|
|
|
|
* behind the second surrogate (i.e., to the first surrogate).
|
|
|
|
* @param offset a valid offset after any code unit of a code point of the text
|
|
|
|
* @return offset of the first code unit after the same code point
|
|
|
|
* @see U16_SET_CP_LIMIT
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2002-11-13 22:36:43 +00:00
|
|
|
*/
|
2011-07-27 05:53:56 +00:00
|
|
|
int32_t getChar32Limit(int32_t offset) const;
|
2002-11-13 22:36:43 +00:00
|
|
|
|
2001-09-17 22:05:21 +00:00
|
|
|
/**
|
|
|
|
* Move the code unit index along the string by delta code points.
|
|
|
|
* Interpret the input index as a code unit-based offset into the string,
|
|
|
|
* move the index forward or backward by delta code points, and
|
|
|
|
* return the resulting index.
|
|
|
|
* The input index should point to the first code unit of a code point,
|
|
|
|
* if there is more than one.
|
|
|
|
*
|
|
|
|
* Both input and output indexes are code unit-based as for all
|
|
|
|
* string indexes/offsets in ICU (and other libraries, like MBCS char*).
|
|
|
|
* If delta<0 then the index is moved backward (toward the start of the string).
|
|
|
|
* If delta>0 then the index is moved forward (toward the end of the string).
|
|
|
|
*
|
|
|
|
* This behaves like CharacterIterator::move32(delta, kCurrent).
|
|
|
|
*
|
2002-10-24 18:30:07 +00:00
|
|
|
* Behavior for out-of-bounds indexes:
|
|
|
|
* <code>moveIndex32</code> pins the input index to 0..length(), i.e.,
|
|
|
|
* if the input index<0 then it is pinned to 0;
|
|
|
|
* if it is index>length() then it is pinned to length().
|
|
|
|
* Afterwards, the index is moved by <code>delta</code> code points
|
|
|
|
* forward or backward,
|
|
|
|
* but no further backward than to 0 and no further forward than to length().
|
|
|
|
* The resulting index return value will be in between 0 and length(), inclusively.
|
|
|
|
*
|
2001-09-17 22:05:21 +00:00
|
|
|
* Examples:
|
|
|
|
* <pre>
|
|
|
|
* // s has code points 'a' U+10000 'b' U+10ffff U+2029
|
|
|
|
* UnicodeString s=UNICODE_STRING("a\\U00010000b\\U0010ffff\\u2029", 31).unescape();
|
|
|
|
*
|
|
|
|
* // initial index: position of U+10000
|
2002-03-12 01:32:42 +00:00
|
|
|
* int32_t index=1;
|
2001-09-17 22:05:21 +00:00
|
|
|
*
|
|
|
|
* // the following examples will all result in index==4, position of U+10ffff
|
|
|
|
*
|
|
|
|
* // skip 2 code points from some position in the string
|
|
|
|
* index=s.moveIndex32(index, 2); // skips U+10000 and 'b'
|
|
|
|
*
|
|
|
|
* // go to the 3rd code point from the start of s (0-based)
|
|
|
|
* index=s.moveIndex32(0, 3); // skips 'a', U+10000, and 'b'
|
|
|
|
*
|
|
|
|
* // go to the next-to-last code point of s
|
|
|
|
* index=s.moveIndex32(s.length(), -2); // backward-skips U+2029 and U+10ffff
|
|
|
|
* </pre>
|
2001-09-19 00:39:10 +00:00
|
|
|
*
|
|
|
|
* @param index input code unit index
|
|
|
|
* @param delta (signed) code point count to move the index forward or backward
|
|
|
|
* in the string
|
|
|
|
* @return the resulting code unit index
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-09-17 22:05:21 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t moveIndex32(int32_t index, int32_t delta) const;
|
2001-09-17 22:05:21 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/* Substring extraction */
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Copy the characters in the range
|
1999-12-28 23:39:02 +00:00
|
|
|
* [<tt>start</tt>, <tt>start + length</tt>) into the array <tt>dst</tt>,
|
|
|
|
* beginning at <tt>dstStart</tt>.
|
2000-03-29 01:13:49 +00:00
|
|
|
* If the string aliases to <code>dst</code> itself as an external buffer,
|
|
|
|
* then extract() will not copy the contents.
|
|
|
|
*
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param start offset of first character which will be copied into the array
|
|
|
|
* @param length the number of characters to extract
|
|
|
|
* @param dst array in which to copy characters. The length of <tt>dst</tt>
|
|
|
|
* must be at least (<tt>dstStart + length</tt>).
|
|
|
|
* @param dstStart the offset in <TT>dst</TT> where the first character
|
|
|
|
* will be extracted
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline void extract(int32_t start,
|
|
|
|
int32_t length,
|
|
|
|
UChar *dst,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t dstStart = 0) const;
|
2001-01-02 19:37:08 +00:00
|
|
|
|
2001-09-05 23:37:56 +00:00
|
|
|
/**
|
|
|
|
* Copy the contents of the string into dest.
|
|
|
|
* This is a convenience function that
|
|
|
|
* checks if there is enough space in dest,
|
|
|
|
* extracts the entire string if possible,
|
|
|
|
* and NUL-terminates dest if possible.
|
|
|
|
*
|
|
|
|
* If the string fits into dest but cannot be NUL-terminated
|
|
|
|
* (length()==destCapacity) then the error code is set to U_STRING_NOT_TERMINATED_WARNING.
|
|
|
|
* If the string itself does not fit into dest
|
|
|
|
* (length()>destCapacity) then the error code is set to U_BUFFER_OVERFLOW_ERROR.
|
|
|
|
*
|
|
|
|
* If the string aliases to <code>dest</code> itself as an external buffer,
|
|
|
|
* then extract() will not copy the contents.
|
|
|
|
*
|
|
|
|
* @param dest Destination string buffer.
|
|
|
|
* @param destCapacity Number of UChars available at dest.
|
|
|
|
* @param errorCode ICU error code.
|
|
|
|
* @return length()
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-09-05 23:37:56 +00:00
|
|
|
*/
|
|
|
|
int32_t
|
|
|
|
extract(UChar *dest, int32_t destCapacity,
|
|
|
|
UErrorCode &errorCode) const;
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Copy the characters in the range
|
1999-12-28 23:39:02 +00:00
|
|
|
* [<tt>start</tt>, <tt>start + length</tt>) into the UnicodeString
|
|
|
|
* <tt>target</tt>.
|
|
|
|
* @param start offset of first character which will be copied
|
|
|
|
* @param length the number of characters to extract
|
|
|
|
* @param target UnicodeString into which to copy characters.
|
|
|
|
* @return A reference to <TT>target</TT>
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline void extract(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length,
|
|
|
|
UnicodeString& target) const;
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>)
|
1999-12-28 23:39:02 +00:00
|
|
|
* into the array <tt>dst</tt>, beginning at <tt>dstStart</tt>.
|
|
|
|
* @param start offset of first character which will be copied into the array
|
|
|
|
* @param limit offset immediately following the last character to be copied
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param dst array in which to copy characters. The length of <tt>dst</tt>
|
1999-12-28 23:39:02 +00:00
|
|
|
* must be at least (<tt>dstStart + (limit - start)</tt>).
|
|
|
|
* @param dstStart the offset in <TT>dst</TT> where the first character
|
|
|
|
* will be extracted
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline void extractBetween(int32_t start,
|
|
|
|
int32_t limit,
|
|
|
|
UChar *dst,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t dstStart = 0) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>)
|
2002-02-26 17:50:59 +00:00
|
|
|
* into the UnicodeString <tt>target</tt>. Replaceable API.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param start offset of first character which will be copied
|
|
|
|
* @param limit offset immediately following the last character to be copied
|
|
|
|
* @param target UnicodeString into which to copy characters.
|
|
|
|
* @return A reference to <TT>target</TT>
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
virtual void extractBetween(int32_t start,
|
|
|
|
int32_t limit,
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString& target) const;
|
|
|
|
|
2004-08-26 22:58:39 +00:00
|
|
|
/**
|
|
|
|
* Copy the characters in the range
|
|
|
|
* [<tt>start</TT>, <tt>start + length</TT>) into an array of characters.
|
|
|
|
* All characters must be invariant (see utypes.h).
|
|
|
|
* Use US_INV as the last, signature-distinguishing parameter.
|
|
|
|
*
|
|
|
|
* This function does not write any more than <code>targetLength</code>
|
|
|
|
* characters but returns the length of the entire output string
|
|
|
|
* so that one can allocate a larger buffer and call the function again
|
|
|
|
* if necessary.
|
|
|
|
* The output string is NUL-terminated if possible.
|
|
|
|
*
|
|
|
|
* @param start offset of first character which will be copied
|
|
|
|
* @param startLength the number of characters to extract
|
|
|
|
* @param target the target buffer for extraction, can be NULL
|
|
|
|
* if targetLength is 0
|
2004-11-02 04:55:53 +00:00
|
|
|
* @param targetCapacity the length of the target buffer
|
2004-08-26 22:58:39 +00:00
|
|
|
* @param inv Signature-distinguishing paramater, use US_INV.
|
|
|
|
* @return the output string length, not including the terminating NUL
|
2006-01-18 03:34:19 +00:00
|
|
|
* @stable ICU 3.2
|
2004-08-26 22:58:39 +00:00
|
|
|
*/
|
|
|
|
int32_t extract(int32_t start,
|
2004-11-02 04:55:53 +00:00
|
|
|
int32_t startLength,
|
2004-08-26 22:58:39 +00:00
|
|
|
char *target,
|
|
|
|
int32_t targetCapacity,
|
|
|
|
enum EInvariant inv) const;
|
|
|
|
|
2009-03-11 23:57:47 +00:00
|
|
|
#if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy the characters in the range
|
|
|
|
* [<tt>start</TT>, <tt>start + length</TT>) into an array of characters
|
|
|
|
* in the platform's default codepage.
|
|
|
|
* This function does not write any more than <code>targetLength</code>
|
|
|
|
* characters but returns the length of the entire output string
|
|
|
|
* so that one can allocate a larger buffer and call the function again
|
|
|
|
* if necessary.
|
|
|
|
* The output string is NUL-terminated if possible.
|
|
|
|
*
|
|
|
|
* @param start offset of first character which will be copied
|
|
|
|
* @param startLength the number of characters to extract
|
|
|
|
* @param target the target buffer for extraction
|
|
|
|
* @param targetLength the length of the target buffer
|
|
|
|
* If <TT>target</TT> is NULL, then the number of bytes required for
|
|
|
|
* <TT>target</TT> is returned.
|
|
|
|
* @return the output string length, not including the terminating NUL
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
int32_t extract(int32_t start,
|
|
|
|
int32_t startLength,
|
|
|
|
char *target,
|
|
|
|
uint32_t targetLength) const;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2004-08-26 22:58:39 +00:00
|
|
|
#if !UCONFIG_NO_CONVERSION
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Copy the characters in the range
|
1999-12-28 23:39:02 +00:00
|
|
|
* [<tt>start</TT>, <tt>start + length</TT>) into an array of characters
|
|
|
|
* in a specified codepage.
|
2001-09-18 01:12:14 +00:00
|
|
|
* The output string is NUL-terminated.
|
|
|
|
*
|
2004-08-26 22:58:39 +00:00
|
|
|
* Recommendation: For invariant-character strings use
|
|
|
|
* extract(int32_t start, int32_t length, char *target, int32_t targetCapacity, enum EInvariant inv) const
|
|
|
|
* because it avoids object code dependencies of UnicodeString on
|
|
|
|
* the conversion code.
|
|
|
|
*
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param start offset of first character which will be copied
|
2000-08-23 02:10:08 +00:00
|
|
|
* @param startLength the number of characters to extract
|
|
|
|
* @param target the target buffer for extraction
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param codepage the desired codepage for the characters. 0 has
|
2000-08-23 02:10:08 +00:00
|
|
|
* the special meaning of the default codepage
|
|
|
|
* If <code>codepage</code> is an empty string (<code>""</code>),
|
|
|
|
* then a simple conversion is performed on the codepage-invariant
|
|
|
|
* subset ("invariant characters") of the platform encoding. See utypes.h.
|
|
|
|
* If <TT>target</TT> is NULL, then the number of bytes required for
|
|
|
|
* <TT>target</TT> is returned. It is assumed that the target is big enough
|
|
|
|
* to fit all of the characters.
|
2007-08-31 19:39:14 +00:00
|
|
|
* @return the output string length, not including the terminating NUL
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-08-23 02:10:08 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline int32_t extract(int32_t start,
|
2000-08-23 02:10:08 +00:00
|
|
|
int32_t startLength,
|
|
|
|
char *target,
|
|
|
|
const char *codepage = 0) const;
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Copy the characters in the range
|
2000-08-23 02:10:08 +00:00
|
|
|
* [<tt>start</TT>, <tt>start + length</TT>) into an array of characters
|
|
|
|
* in a specified codepage.
|
2001-09-18 01:12:14 +00:00
|
|
|
* This function does not write any more than <code>targetLength</code>
|
|
|
|
* characters but returns the length of the entire output string
|
|
|
|
* so that one can allocate a larger buffer and call the function again
|
|
|
|
* if necessary.
|
|
|
|
* The output string is NUL-terminated if possible.
|
|
|
|
*
|
2004-08-26 22:58:39 +00:00
|
|
|
* Recommendation: For invariant-character strings use
|
|
|
|
* extract(int32_t start, int32_t length, char *target, int32_t targetCapacity, enum EInvariant inv) const
|
|
|
|
* because it avoids object code dependencies of UnicodeString on
|
|
|
|
* the conversion code.
|
|
|
|
*
|
2000-08-23 02:10:08 +00:00
|
|
|
* @param start offset of first character which will be copied
|
|
|
|
* @param startLength the number of characters to extract
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param target the target buffer for extraction
|
2000-08-23 02:10:08 +00:00
|
|
|
* @param targetLength the length of the target buffer
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param codepage the desired codepage for the characters. 0 has
|
1999-12-28 23:39:02 +00:00
|
|
|
* the special meaning of the default codepage
|
|
|
|
* If <code>codepage</code> is an empty string (<code>""</code>),
|
|
|
|
* then a simple conversion is performed on the codepage-invariant
|
|
|
|
* subset ("invariant characters") of the platform encoding. See utypes.h.
|
2000-08-23 02:10:08 +00:00
|
|
|
* If <TT>target</TT> is NULL, then the number of bytes required for
|
|
|
|
* <TT>target</TT> is returned.
|
2001-09-18 01:12:14 +00:00
|
|
|
* @return the output string length, not including the terminating NUL
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t extract(int32_t start,
|
2000-08-23 02:10:08 +00:00
|
|
|
int32_t startLength,
|
|
|
|
char *target,
|
|
|
|
uint32_t targetLength,
|
2009-03-11 23:57:47 +00:00
|
|
|
const char *codepage) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2001-09-18 01:12:14 +00:00
|
|
|
/**
|
|
|
|
* Convert the UnicodeString into a codepage string using an existing UConverter.
|
|
|
|
* The output string is NUL-terminated if possible.
|
|
|
|
*
|
|
|
|
* This function avoids the overhead of opening and closing a converter if
|
|
|
|
* multiple strings are extracted.
|
|
|
|
*
|
|
|
|
* @param dest destination string buffer, can be NULL if destCapacity==0
|
|
|
|
* @param destCapacity the number of chars available at dest
|
|
|
|
* @param cnv the converter object to be used (ucnv_resetFromUnicode() will be called),
|
|
|
|
* or NULL for the default converter
|
|
|
|
* @param errorCode normal ICU error code
|
2007-08-31 19:39:14 +00:00
|
|
|
* @return the length of the output string, not counting the terminating NUL;
|
|
|
|
* if the length is greater than destCapacity, then the string will not fit
|
|
|
|
* and a buffer of the indicated length would need to be passed in
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-09-18 01:12:14 +00:00
|
|
|
*/
|
|
|
|
int32_t extract(char *dest, int32_t destCapacity,
|
|
|
|
UConverter *cnv,
|
|
|
|
UErrorCode &errorCode) const;
|
|
|
|
|
2009-03-06 19:19:00 +00:00
|
|
|
#endif
|
|
|
|
|
2010-01-06 23:50:03 +00:00
|
|
|
/**
|
|
|
|
* Create a temporary substring for the specified range.
|
|
|
|
* Unlike the substring constructor and setTo() functions,
|
|
|
|
* the object returned here will be a read-only alias (using getBuffer())
|
|
|
|
* rather than copying the text.
|
|
|
|
* As a result, this substring operation is much faster but requires
|
|
|
|
* that the original string not be modified or deleted during the lifetime
|
|
|
|
* of the returned substring object.
|
|
|
|
* @param start offset of the first character visible in the substring
|
|
|
|
* @param length length of the substring
|
|
|
|
* @return a read-only alias UnicodeString object for the substring
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-06 23:50:03 +00:00
|
|
|
*/
|
|
|
|
UnicodeString tempSubString(int32_t start=0, int32_t length=INT32_MAX) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a temporary substring for the specified range.
|
|
|
|
* Same as tempSubString(start, length) except that the substring range
|
|
|
|
* is specified as a (start, limit) pair (with an exclusive limit index)
|
|
|
|
* rather than a (start, length) pair.
|
|
|
|
* @param start offset of the first character visible in the substring
|
|
|
|
* @param limit offset immediately following the last character visible in the substring
|
|
|
|
* @return a read-only alias UnicodeString object for the substring
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-06 23:50:03 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString tempSubStringBetween(int32_t start, int32_t limit=INT32_MAX) const;
|
|
|
|
|
2009-03-06 19:19:00 +00:00
|
|
|
/**
|
|
|
|
* Convert the UnicodeString to UTF-8 and write the result
|
|
|
|
* to a ByteSink. This is called by toUTF8String().
|
|
|
|
* Unpaired surrogates are replaced with U+FFFD.
|
|
|
|
* Calls u_strToUTF8WithSub().
|
|
|
|
*
|
2009-03-17 01:47:25 +00:00
|
|
|
* @param sink A ByteSink to which the UTF-8 version of the string is written.
|
2010-06-15 15:54:53 +00:00
|
|
|
* sink.Flush() is called at the end.
|
2010-01-28 21:09:53 +00:00
|
|
|
* @stable ICU 4.2
|
2009-03-06 19:19:00 +00:00
|
|
|
* @see toUTF8String
|
|
|
|
*/
|
|
|
|
void toUTF8(ByteSink &sink) const;
|
|
|
|
|
|
|
|
#if U_HAVE_STD_STRING
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert the UnicodeString to UTF-8 and append the result
|
|
|
|
* to a standard string.
|
|
|
|
* Unpaired surrogates are replaced with U+FFFD.
|
|
|
|
* Calls toUTF8().
|
|
|
|
*
|
2010-01-19 23:39:42 +00:00
|
|
|
* @param result A standard string (or a compatible object)
|
2009-03-06 19:19:00 +00:00
|
|
|
* to which the UTF-8 version of the string is appended.
|
|
|
|
* @return The string object.
|
2010-01-28 21:09:53 +00:00
|
|
|
* @stable ICU 4.2
|
2009-03-06 19:19:00 +00:00
|
|
|
* @see toUTF8
|
|
|
|
*/
|
|
|
|
template<typename StringClass>
|
|
|
|
StringClass &toUTF8String(StringClass &result) const {
|
2009-03-09 02:54:18 +00:00
|
|
|
StringByteSink<StringClass> sbs(&result);
|
|
|
|
toUTF8(sbs);
|
2009-03-06 19:19:00 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2004-08-26 22:58:39 +00:00
|
|
|
#endif
|
|
|
|
|
2009-02-19 22:35:06 +00:00
|
|
|
/**
|
|
|
|
* Convert the UnicodeString to UTF-32.
|
|
|
|
* Unpaired surrogates are replaced with U+FFFD.
|
|
|
|
* Calls u_strToUTF32WithSub().
|
|
|
|
*
|
|
|
|
* @param utf32 destination string buffer, can be NULL if capacity==0
|
|
|
|
* @param capacity the number of UChar32s available at utf32
|
|
|
|
* @param errorCode Standard ICU error code. Its input value must
|
|
|
|
* pass the U_SUCCESS() test, or else the function returns
|
|
|
|
* immediately. Check for U_FAILURE() on output or use with
|
|
|
|
* function chaining. (See User Guide for details.)
|
|
|
|
* @return The length of the UTF-32 string.
|
|
|
|
* @see fromUTF32
|
2010-01-28 21:09:53 +00:00
|
|
|
* @stable ICU 4.2
|
2009-02-19 22:35:06 +00:00
|
|
|
*/
|
|
|
|
int32_t toUTF32(UChar32 *utf32, int32_t capacity, UErrorCode &errorCode) const;
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/* Length operations */
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Return the length of the UnicodeString object.
|
2003-10-21 17:06:04 +00:00
|
|
|
* The length is the number of UChar code units are in the UnicodeString.
|
|
|
|
* If you want the number of code points, please use countChar32().
|
2002-10-09 21:37:48 +00:00
|
|
|
* @return the length of the UnicodeString object
|
2003-10-21 17:06:04 +00:00
|
|
|
* @see countChar32
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-10-09 21:37:48 +00:00
|
|
|
inline int32_t length(void) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2001-10-11 21:40:24 +00:00
|
|
|
/**
|
|
|
|
* Count Unicode code points in the length UChar code units of the string.
|
|
|
|
* A code point may occupy either one or two UChar code units.
|
|
|
|
* Counting code points involves reading all code units.
|
|
|
|
*
|
|
|
|
* This functions is basically the inverse of moveIndex32().
|
|
|
|
*
|
|
|
|
* @param start the index of the first code unit to check
|
|
|
|
* @param length the number of UChar code units to check
|
|
|
|
* @return the number of code points in the specified code units
|
2003-10-21 17:06:04 +00:00
|
|
|
* @see length
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-10-11 21:40:24 +00:00
|
|
|
*/
|
|
|
|
int32_t
|
2002-11-19 02:12:39 +00:00
|
|
|
countChar32(int32_t start=0, int32_t length=INT32_MAX) const;
|
2001-10-11 21:40:24 +00:00
|
|
|
|
2002-10-09 21:37:48 +00:00
|
|
|
/**
|
|
|
|
* Check if the length UChar code units of the string
|
|
|
|
* contain more Unicode code points than a certain number.
|
|
|
|
* This is more efficient than counting all code points in this part of the string
|
|
|
|
* and comparing that number with a threshold.
|
|
|
|
* This function may not need to scan the string at all if the length
|
|
|
|
* falls within a certain range, and
|
|
|
|
* never needs to count more than 'number+1' code points.
|
|
|
|
* Logically equivalent to (countChar32(start, length)>number).
|
|
|
|
* A Unicode code point may occupy either one or two UChar code units.
|
|
|
|
*
|
|
|
|
* @param start the index of the first code unit to check (0 for the entire string)
|
|
|
|
* @param length the number of UChar code units to check
|
2002-11-19 02:12:39 +00:00
|
|
|
* (use INT32_MAX for the entire string; remember that start/length
|
2002-10-09 21:37:48 +00:00
|
|
|
* values are pinned)
|
|
|
|
* @param number The number of code points in the (sub)string is compared against
|
|
|
|
* the 'number' parameter.
|
|
|
|
* @return Boolean value for whether the string contains more Unicode code points
|
|
|
|
* than 'number'. Same as (u_countChar32(s, length)>number).
|
|
|
|
* @see countChar32
|
|
|
|
* @see u_strHasMoreChar32Than
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-10-09 21:37:48 +00:00
|
|
|
*/
|
|
|
|
UBool
|
|
|
|
hasMoreChar32Than(int32_t start, int32_t length, int32_t number) const;
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Determine if this string is empty.
|
|
|
|
* @return TRUE if this string contains 0 characters, FALSE otherwise.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-09-27 22:37:55 +00:00
|
|
|
*/
|
|
|
|
inline UBool isEmpty(void) const;
|
|
|
|
|
2001-10-05 20:44:56 +00:00
|
|
|
/**
|
|
|
|
* Return the capacity of the internal buffer of the UnicodeString object.
|
|
|
|
* This is useful together with the getBuffer functions.
|
|
|
|
* See there for details.
|
|
|
|
*
|
|
|
|
* @return the number of UChars available in the internal buffer
|
|
|
|
* @see getBuffer
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-10-05 20:44:56 +00:00
|
|
|
*/
|
|
|
|
inline int32_t getCapacity(void) const;
|
2000-08-23 02:10:08 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/* Other operations */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a hash code for this object.
|
|
|
|
* @return The hash code of this UnicodeString.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline int32_t hashCode(void) const;
|
|
|
|
|
|
|
|
/**
|
2002-11-26 23:43:49 +00:00
|
|
|
* Determine if this object contains a valid string.
|
2010-02-26 00:37:44 +00:00
|
|
|
* A bogus string has no value. It is different from an empty string,
|
|
|
|
* although in both cases isEmpty() returns TRUE and length() returns 0.
|
|
|
|
* setToBogus() and isBogus() can be used to indicate that no string value is available.
|
|
|
|
* For a bogus string, getBuffer() and getTerminatedBuffer() return NULL, and
|
2002-11-26 23:43:49 +00:00
|
|
|
* length() returns 0.
|
2002-11-16 01:05:36 +00:00
|
|
|
*
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return TRUE if the string is valid, FALSE otherwise
|
2001-10-05 23:53:00 +00:00
|
|
|
* @see setToBogus()
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool isBogus(void) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2001-01-02 19:37:08 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
//========================================
|
|
|
|
// Write operations
|
|
|
|
//========================================
|
|
|
|
|
|
|
|
/* Assignment operations */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assignment operator. Replace the characters in this UnicodeString
|
|
|
|
* with the characters from <TT>srcText</TT>.
|
|
|
|
* @param srcText The text containing the characters to replace
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-10-12 00:59:36 +00:00
|
|
|
UnicodeString &operator=(const UnicodeString &srcText);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Almost the same as the assignment operator.
|
|
|
|
* Replace the characters in this UnicodeString
|
|
|
|
* with the characters from <code>srcText</code>.
|
|
|
|
*
|
2012-06-06 17:35:12 +00:00
|
|
|
* This function works the same as the assignment operator
|
|
|
|
* for all strings except for ones that are readonly aliases.
|
|
|
|
*
|
2002-10-12 00:59:36 +00:00
|
|
|
* Starting with ICU 2.4, the assignment operator and the copy constructor
|
|
|
|
* allocate a new buffer and copy the buffer contents even for readonly aliases.
|
|
|
|
* This function implements the old, more efficient but less safe behavior
|
|
|
|
* of making this string also a readonly alias to the same buffer.
|
2012-06-06 17:35:12 +00:00
|
|
|
*
|
2002-10-12 00:59:36 +00:00
|
|
|
* The fastCopyFrom function must be used only if it is known that the lifetime of
|
2012-06-08 17:58:13 +00:00
|
|
|
* this UnicodeString does not exceed the lifetime of the aliased buffer
|
2002-10-12 00:59:36 +00:00
|
|
|
* including its contents, for example for strings from resource bundles
|
2012-06-06 17:35:12 +00:00
|
|
|
* or aliases to string constants.
|
2002-10-12 00:59:36 +00:00
|
|
|
*
|
|
|
|
* @param src The text containing the characters to replace.
|
|
|
|
* @return a reference to this
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-10-12 00:59:36 +00:00
|
|
|
*/
|
|
|
|
UnicodeString &fastCopyFrom(const UnicodeString &src);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assignment operator. Replace the characters in this UnicodeString
|
2000-05-24 20:03:21 +00:00
|
|
|
* with the code unit <TT>ch</TT>.
|
|
|
|
* @param ch the code unit to replace
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString& operator= (UChar ch);
|
|
|
|
|
2000-05-24 20:03:21 +00:00
|
|
|
/**
|
|
|
|
* Assignment operator. Replace the characters in this UnicodeString
|
|
|
|
* with the code point <TT>ch</TT>.
|
|
|
|
* @param ch the code point to replace
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-05-24 20:03:21 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString& operator= (UChar32 ch);
|
|
|
|
|
2002-04-26 18:02:49 +00:00
|
|
|
/**
|
|
|
|
* Set the text in the UnicodeString object to the characters
|
2004-08-24 17:21:14 +00:00
|
|
|
* in <TT>srcText</TT> in the range
|
2002-04-26 18:02:49 +00:00
|
|
|
* [<TT>srcStart</TT>, <TT>srcText.length()</TT>).
|
|
|
|
* <TT>srcText</TT> is not modified.
|
|
|
|
* @param srcText the source for the new characters
|
|
|
|
* @param srcStart the offset into <TT>srcText</TT> where new characters
|
|
|
|
* will be obtained
|
|
|
|
* @return a reference to this
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-04-26 18:02:49 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& setTo(const UnicodeString& srcText,
|
2002-04-26 18:02:49 +00:00
|
|
|
int32_t srcStart);
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Set the text in the UnicodeString object to the characters
|
2004-08-24 17:21:14 +00:00
|
|
|
* in <TT>srcText</TT> in the range
|
1999-12-28 23:39:02 +00:00
|
|
|
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
|
|
|
|
* <TT>srcText</TT> is not modified.
|
|
|
|
* @param srcText the source for the new characters
|
|
|
|
* @param srcStart the offset into <TT>srcText</TT> where new characters
|
|
|
|
* will be obtained
|
|
|
|
* @param srcLength the number of characters in <TT>srcText</TT> in the
|
|
|
|
* replace string.
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& setTo(const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Set the text in the UnicodeString object to the characters in
|
|
|
|
* <TT>srcText</TT>.
|
1999-12-28 23:39:02 +00:00
|
|
|
* <TT>srcText</TT> is not modified.
|
|
|
|
* @param srcText the source for the new characters
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString& setTo(const UnicodeString& srcText);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the characters in the UnicodeString object to the characters
|
|
|
|
* in <TT>srcChars</TT>. <TT>srcChars</TT> is not modified.
|
|
|
|
* @param srcChars the source for the new characters
|
|
|
|
* @param srcLength the number of Unicode characters in srcChars.
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString& setTo(const UChar *srcChars,
|
|
|
|
int32_t srcLength);
|
|
|
|
|
|
|
|
/**
|
2000-05-24 20:03:21 +00:00
|
|
|
* Set the characters in the UnicodeString object to the code unit
|
1999-12-28 23:39:02 +00:00
|
|
|
* <TT>srcChar</TT>.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcChar the code unit which becomes the UnicodeString's character
|
1999-12-28 23:39:02 +00:00
|
|
|
* content
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
UnicodeString& setTo(UChar srcChar);
|
|
|
|
|
2000-05-24 20:03:21 +00:00
|
|
|
/**
|
|
|
|
* Set the characters in the UnicodeString object to the code point
|
|
|
|
* <TT>srcChar</TT>.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcChar the code point which becomes the UnicodeString's character
|
2000-05-24 20:03:21 +00:00
|
|
|
* content
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-05-24 20:03:21 +00:00
|
|
|
*/
|
|
|
|
UnicodeString& setTo(UChar32 srcChar);
|
|
|
|
|
2000-03-29 01:13:49 +00:00
|
|
|
/**
|
|
|
|
* Aliasing setTo() function, analogous to the readonly-aliasing UChar* constructor.
|
|
|
|
* The text will be used for the UnicodeString object, but
|
|
|
|
* it will not be released when the UnicodeString is destroyed.
|
|
|
|
* This has copy-on-write semantics:
|
|
|
|
* When the string is modified, then the buffer is first copied into
|
|
|
|
* newly allocated memory.
|
|
|
|
* The aliased buffer is never modified.
|
2012-06-06 17:35:12 +00:00
|
|
|
*
|
|
|
|
* In an assignment to another UnicodeString, when using the copy constructor
|
|
|
|
* or the assignment operator, the text will be copied.
|
|
|
|
* When using fastCopyFrom(), the text will be aliased again,
|
2000-03-29 01:13:49 +00:00
|
|
|
* so that both strings then alias the same readonly-text.
|
|
|
|
*
|
|
|
|
* @param isTerminated specifies if <code>text</code> is <code>NUL</code>-terminated.
|
|
|
|
* This must be true if <code>textLength==-1</code>.
|
|
|
|
* @param text The characters to alias for the UnicodeString.
|
|
|
|
* @param textLength The number of Unicode characters in <code>text</code> to alias.
|
|
|
|
* If -1, then this constructor will determine the length
|
|
|
|
* by calling <code>u_strlen()</code>.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-29 01:13:49 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
UnicodeString &setTo(UBool isTerminated,
|
2000-03-29 01:13:49 +00:00
|
|
|
const UChar *text,
|
|
|
|
int32_t textLength);
|
|
|
|
|
|
|
|
/**
|
2001-09-20 01:14:37 +00:00
|
|
|
* Aliasing setTo() function, analogous to the writable-aliasing UChar* constructor.
|
2000-03-29 01:13:49 +00:00
|
|
|
* The text will be used for the UnicodeString object, but
|
|
|
|
* it will not be released when the UnicodeString is destroyed.
|
|
|
|
* This has write-through semantics:
|
|
|
|
* For as long as the capacity of the buffer is sufficient, write operations
|
|
|
|
* will directly affect the buffer. When more capacity is necessary, then
|
|
|
|
* a new buffer will be allocated and the contents copied as with regularly
|
|
|
|
* constructed strings.
|
|
|
|
* In an assignment to another UnicodeString, the buffer will be copied.
|
|
|
|
* The extract(UChar *dst) function detects whether the dst pointer is the same
|
|
|
|
* as the string buffer itself and will in this case not copy the contents.
|
|
|
|
*
|
|
|
|
* @param buffer The characters to alias for the UnicodeString.
|
|
|
|
* @param buffLength The number of Unicode characters in <code>buffer</code> to alias.
|
|
|
|
* @param buffCapacity The size of <code>buffer</code> in UChars.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-29 01:13:49 +00:00
|
|
|
*/
|
|
|
|
UnicodeString &setTo(UChar *buffer,
|
|
|
|
int32_t buffLength,
|
|
|
|
int32_t buffCapacity);
|
|
|
|
|
2001-10-05 23:53:00 +00:00
|
|
|
/**
|
|
|
|
* Make this UnicodeString object invalid.
|
|
|
|
* The string will test TRUE with isBogus().
|
|
|
|
*
|
2002-11-26 23:43:49 +00:00
|
|
|
* A bogus string has no value. It is different from an empty string.
|
|
|
|
* It can be used to indicate that no string value is available.
|
|
|
|
* getBuffer() and getTerminatedBuffer() return NULL, and
|
|
|
|
* length() returns 0.
|
|
|
|
*
|
2001-10-05 23:53:00 +00:00
|
|
|
* This utility function is used throughout the UnicodeString
|
2002-11-26 23:43:49 +00:00
|
|
|
* implementation to indicate that a UnicodeString operation failed,
|
|
|
|
* and may be used in other functions,
|
2001-10-05 23:53:00 +00:00
|
|
|
* especially but not exclusively when such functions do not
|
|
|
|
* take a UErrorCode for simplicity.
|
|
|
|
*
|
2002-11-26 00:08:40 +00:00
|
|
|
* The following methods, and no others, will clear a string object's bogus flag:
|
|
|
|
* - remove()
|
|
|
|
* - remove(0, INT32_MAX)
|
|
|
|
* - truncate(0)
|
|
|
|
* - operator=() (assignment operator)
|
|
|
|
* - setTo(...)
|
2002-11-16 01:05:36 +00:00
|
|
|
*
|
|
|
|
* The simplest ways to turn a bogus string into an empty one
|
2002-11-19 02:12:39 +00:00
|
|
|
* is to use the remove() function.
|
|
|
|
* Examples for other functions that are equivalent to "set to empty string":
|
2002-11-16 01:05:36 +00:00
|
|
|
* \code
|
|
|
|
* if(s.isBogus()) {
|
2002-11-19 02:12:39 +00:00
|
|
|
* s.remove(); // set to an empty string (remove all), or
|
|
|
|
* s.remove(0, INT32_MAX); // set to an empty string (remove all), or
|
|
|
|
* s.truncate(0); // set to an empty string (complete truncation), or
|
2002-11-16 01:05:36 +00:00
|
|
|
* s=UnicodeString(); // assign an empty string, or
|
|
|
|
* s.setTo((UChar32)-1); // set to a pseudo code point that is out of range, or
|
|
|
|
* static const UChar nul=0;
|
|
|
|
* s.setTo(&nul, 0); // set to an empty C Unicode string
|
|
|
|
* }
|
|
|
|
* \endcode
|
2001-10-05 23:53:00 +00:00
|
|
|
*
|
|
|
|
* @see isBogus()
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-10-05 23:53:00 +00:00
|
|
|
*/
|
|
|
|
void setToBogus();
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Set the character at the specified offset to the specified character.
|
|
|
|
* @param offset A valid offset into the text of the character to set
|
|
|
|
* @param ch The new character
|
|
|
|
* @return A reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
UnicodeString& setCharAt(int32_t offset,
|
1999-12-28 23:39:02 +00:00
|
|
|
UChar ch);
|
|
|
|
|
|
|
|
|
|
|
|
/* Append operations */
|
|
|
|
|
|
|
|
/**
|
2000-04-03 23:53:59 +00:00
|
|
|
* Append operator. Append the code unit <TT>ch</TT> to the UnicodeString
|
1999-12-28 23:39:02 +00:00
|
|
|
* object.
|
2000-04-03 23:53:59 +00:00
|
|
|
* @param ch the code unit to be appended
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString& operator+= (UChar ch);
|
|
|
|
|
2000-04-03 23:53:59 +00:00
|
|
|
/**
|
|
|
|
* Append operator. Append the code point <TT>ch</TT> to the UnicodeString
|
|
|
|
* object.
|
|
|
|
* @param ch the code point to be appended
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-04-03 23:53:59 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString& operator+= (UChar32 ch);
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Append operator. Append the characters in <TT>srcText</TT> to the
|
2011-04-29 18:54:10 +00:00
|
|
|
* UnicodeString object. <TT>srcText</TT> is not modified.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param srcText the source for the new characters
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString& operator+= (const UnicodeString& srcText);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Append the characters
|
2004-08-24 17:21:14 +00:00
|
|
|
* in <TT>srcText</TT> in the range
|
|
|
|
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) to the
|
|
|
|
* UnicodeString object at offset <TT>start</TT>. <TT>srcText</TT>
|
1999-12-28 23:39:02 +00:00
|
|
|
* is not modified.
|
|
|
|
* @param srcText the source for the new characters
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcStart the offset into <TT>srcText</TT> where new characters
|
1999-12-28 23:39:02 +00:00
|
|
|
* will be obtained
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcLength the number of characters in <TT>srcText</TT> in
|
1999-12-28 23:39:02 +00:00
|
|
|
* the append string
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& append(const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength);
|
|
|
|
|
|
|
|
/**
|
2011-04-29 18:54:10 +00:00
|
|
|
* Append the characters in <TT>srcText</TT> to the UnicodeString object.
|
|
|
|
* <TT>srcText</TT> is not modified.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param srcText the source for the new characters
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString& append(const UnicodeString& srcText);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Append the characters in <TT>srcChars</TT> in the range
|
|
|
|
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) to the UnicodeString
|
|
|
|
* object at offset
|
1999-12-28 23:39:02 +00:00
|
|
|
* <TT>start</TT>. <TT>srcChars</TT> is not modified.
|
|
|
|
* @param srcChars the source for the new characters
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcStart the offset into <TT>srcChars</TT> where new characters
|
1999-12-28 23:39:02 +00:00
|
|
|
* will be obtained
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT> in
|
2011-02-03 05:28:01 +00:00
|
|
|
* the append string; can be -1 if <TT>srcChars</TT> is NUL-terminated
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& append(const UChar *srcChars,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Append the characters in <TT>srcChars</TT> to the UnicodeString object
|
1999-12-28 23:39:02 +00:00
|
|
|
* at offset <TT>start</TT>. <TT>srcChars</TT> is not modified.
|
|
|
|
* @param srcChars the source for the new characters
|
2011-02-03 05:28:01 +00:00
|
|
|
* @param srcLength the number of Unicode characters in <TT>srcChars</TT>;
|
|
|
|
* can be -1 if <TT>srcChars</TT> is NUL-terminated
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString& append(const UChar *srcChars,
|
|
|
|
int32_t srcLength);
|
|
|
|
|
|
|
|
/**
|
2000-04-03 23:53:59 +00:00
|
|
|
* Append the code unit <TT>srcChar</TT> to the UnicodeString object.
|
|
|
|
* @param srcChar the code unit to append
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString& append(UChar srcChar);
|
|
|
|
|
2000-04-03 23:53:59 +00:00
|
|
|
/**
|
|
|
|
* Append the code point <TT>srcChar</TT> to the UnicodeString object.
|
|
|
|
* @param srcChar the code point to append
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-04-03 23:53:59 +00:00
|
|
|
*/
|
2011-07-27 05:53:56 +00:00
|
|
|
UnicodeString& append(UChar32 srcChar);
|
2000-04-03 23:53:59 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/* Insert operations */
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Insert the characters in <TT>srcText</TT> in the range
|
|
|
|
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) into the UnicodeString
|
1999-12-28 23:39:02 +00:00
|
|
|
* object at offset <TT>start</TT>. <TT>srcText</TT> is not modified.
|
|
|
|
* @param start the offset where the insertion begins
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcText the source for the new characters
|
|
|
|
* @param srcStart the offset into <TT>srcText</TT> where new characters
|
1999-12-28 23:39:02 +00:00
|
|
|
* will be obtained
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcLength the number of characters in <TT>srcText</TT> in
|
1999-12-28 23:39:02 +00:00
|
|
|
* the insert string
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& insert(int32_t start,
|
|
|
|
const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Insert the characters in <TT>srcText</TT> into the UnicodeString object
|
|
|
|
* at offset <TT>start</TT>. <TT>srcText</TT> is not modified.
|
|
|
|
* @param start the offset where the insertion begins
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcText the source for the new characters
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& insert(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UnicodeString& srcText);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Insert the characters in <TT>srcChars</TT> in the range
|
1999-12-28 23:39:02 +00:00
|
|
|
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) into the UnicodeString
|
|
|
|
* object at offset <TT>start</TT>. <TT>srcChars</TT> is not modified.
|
|
|
|
* @param start the offset at which the insertion begins
|
|
|
|
* @param srcChars the source for the new characters
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcStart the offset into <TT>srcChars</TT> where new characters
|
1999-12-28 23:39:02 +00:00
|
|
|
* will be obtained
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT>
|
1999-12-28 23:39:02 +00:00
|
|
|
* in the insert string
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& insert(int32_t start,
|
|
|
|
const UChar *srcChars,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Insert the characters in <TT>srcChars</TT> into the UnicodeString object
|
1999-12-28 23:39:02 +00:00
|
|
|
* at offset <TT>start</TT>. <TT>srcChars</TT> is not modified.
|
|
|
|
* @param start the offset where the insertion begins
|
|
|
|
* @param srcChars the source for the new characters
|
|
|
|
* @param srcLength the number of Unicode characters in srcChars.
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& insert(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UChar *srcChars,
|
|
|
|
int32_t srcLength);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Insert the code unit <TT>srcChar</TT> into the UnicodeString object at
|
1999-12-28 23:39:02 +00:00
|
|
|
* offset <TT>start</TT>.
|
|
|
|
* @param start the offset at which the insertion occurs
|
2000-05-24 20:03:21 +00:00
|
|
|
* @param srcChar the code unit to insert
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& insert(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
UChar srcChar);
|
|
|
|
|
2000-05-24 20:03:21 +00:00
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Insert the code point <TT>srcChar</TT> into the UnicodeString object at
|
2000-05-24 20:03:21 +00:00
|
|
|
* offset <TT>start</TT>.
|
|
|
|
* @param start the offset at which the insertion occurs
|
|
|
|
* @param srcChar the code point to insert
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-05-24 20:03:21 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& insert(int32_t start,
|
2000-05-24 20:03:21 +00:00
|
|
|
UChar32 srcChar);
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/* Replace operations */
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Replace the characters in the range
|
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) with the characters in
|
|
|
|
* <TT>srcText</TT> in the range
|
|
|
|
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
|
1999-12-28 23:39:02 +00:00
|
|
|
* <TT>srcText</TT> is not modified.
|
|
|
|
* @param start the offset at which the replace operation begins
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param length the number of characters to replace. The character at
|
1999-12-28 23:39:02 +00:00
|
|
|
* <TT>start + length</TT> is not modified.
|
|
|
|
* @param srcText the source for the new characters
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcStart the offset into <TT>srcText</TT> where new characters
|
1999-12-28 23:39:02 +00:00
|
|
|
* will be obtained
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcLength the number of characters in <TT>srcText</TT> in
|
1999-12-28 23:39:02 +00:00
|
|
|
* the replace string
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
UnicodeString& replace(int32_t start,
|
|
|
|
int32_t length,
|
|
|
|
const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Replace the characters in the range
|
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>)
|
1999-12-28 23:39:02 +00:00
|
|
|
* with the characters in <TT>srcText</TT>. <TT>srcText</TT> is
|
|
|
|
* not modified.
|
|
|
|
* @param start the offset at which the replace operation begins
|
|
|
|
* @param length the number of characters to replace. The character at
|
|
|
|
* <TT>start + length</TT> is not modified.
|
|
|
|
* @param srcText the source for the new characters
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
UnicodeString& replace(int32_t start,
|
|
|
|
int32_t length,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UnicodeString& srcText);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Replace the characters in the range
|
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) with the characters in
|
|
|
|
* <TT>srcChars</TT> in the range
|
|
|
|
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>). <TT>srcChars</TT>
|
1999-12-28 23:39:02 +00:00
|
|
|
* is not modified.
|
|
|
|
* @param start the offset at which the replace operation begins
|
|
|
|
* @param length the number of characters to replace. The character at
|
|
|
|
* <TT>start + length</TT> is not modified.
|
|
|
|
* @param srcChars the source for the new characters
|
|
|
|
* @param srcStart the offset into <TT>srcChars</TT> where new characters
|
|
|
|
* will be obtained
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcLength the number of characters in <TT>srcChars</TT>
|
1999-12-28 23:39:02 +00:00
|
|
|
* in the replace string
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
UnicodeString& replace(int32_t start,
|
|
|
|
int32_t length,
|
|
|
|
const UChar *srcChars,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Replace the characters in the range
|
1999-12-28 23:39:02 +00:00
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) with the characters in
|
|
|
|
* <TT>srcChars</TT>. <TT>srcChars</TT> is not modified.
|
|
|
|
* @param start the offset at which the replace operation begins
|
|
|
|
* @param length number of characters to replace. The character at
|
|
|
|
* <TT>start + length</TT> is not modified.
|
|
|
|
* @param srcChars the source for the new characters
|
|
|
|
* @param srcLength the number of Unicode characters in srcChars
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& replace(int32_t start,
|
|
|
|
int32_t length,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UChar *srcChars,
|
|
|
|
int32_t srcLength);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Replace the characters in the range
|
2000-05-24 20:03:21 +00:00
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) with the code unit
|
1999-12-28 23:39:02 +00:00
|
|
|
* <TT>srcChar</TT>.
|
|
|
|
* @param start the offset at which the replace operation begins
|
|
|
|
* @param length the number of characters to replace. The character at
|
|
|
|
* <TT>start + length</TT> is not modified.
|
2000-05-24 20:03:21 +00:00
|
|
|
* @param srcChar the new code unit
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& replace(int32_t start,
|
|
|
|
int32_t length,
|
1999-12-28 23:39:02 +00:00
|
|
|
UChar srcChar);
|
|
|
|
|
2000-05-24 20:03:21 +00:00
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Replace the characters in the range
|
2000-05-24 20:03:21 +00:00
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) with the code point
|
|
|
|
* <TT>srcChar</TT>.
|
|
|
|
* @param start the offset at which the replace operation begins
|
|
|
|
* @param length the number of characters to replace. The character at
|
|
|
|
* <TT>start + length</TT> is not modified.
|
|
|
|
* @param srcChar the new code point
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-05-24 20:03:21 +00:00
|
|
|
*/
|
2011-07-27 05:53:56 +00:00
|
|
|
UnicodeString& replace(int32_t start, int32_t length, UChar32 srcChar);
|
2000-05-24 20:03:21 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Replace the characters in the range [<TT>start</TT>, <TT>limit</TT>)
|
1999-12-28 23:39:02 +00:00
|
|
|
* with the characters in <TT>srcText</TT>. <TT>srcText</TT> is not modified.
|
|
|
|
* @param start the offset at which the replace operation begins
|
|
|
|
* @param limit the offset immediately following the replace range
|
|
|
|
* @param srcText the source for the new characters
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& replaceBetween(int32_t start,
|
|
|
|
int32_t limit,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UnicodeString& srcText);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Replace the characters in the range [<TT>start</TT>, <TT>limit</TT>)
|
|
|
|
* with the characters in <TT>srcText</TT> in the range
|
1999-12-28 23:39:02 +00:00
|
|
|
* [<TT>srcStart</TT>, <TT>srcLimit</TT>). <TT>srcText</TT> is not modified.
|
|
|
|
* @param start the offset at which the replace operation begins
|
|
|
|
* @param limit the offset immediately following the replace range
|
|
|
|
* @param srcText the source for the new characters
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcStart the offset into <TT>srcChars</TT> where new characters
|
1999-12-28 23:39:02 +00:00
|
|
|
* will be obtained
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param srcLimit the offset immediately following the range to copy
|
1999-12-28 23:39:02 +00:00
|
|
|
* in <TT>srcText</TT>
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& replaceBetween(int32_t start,
|
|
|
|
int32_t limit,
|
|
|
|
const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcLimit);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Replace a substring of this object with the given text.
|
|
|
|
* @param start the beginning index, inclusive; <code>0 <= start
|
|
|
|
* <= limit</code>.
|
|
|
|
* @param limit the ending index, exclusive; <code>start <= limit
|
|
|
|
* <= length()</code>.
|
|
|
|
* @param text the text to replace characters <code>start</code>
|
|
|
|
* to <code>limit - 1</code>
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
virtual void handleReplaceBetween(int32_t start,
|
|
|
|
int32_t limit,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UnicodeString& text);
|
|
|
|
|
2002-07-03 01:03:46 +00:00
|
|
|
/**
|
|
|
|
* Replaceable API
|
2002-07-03 12:05:56 +00:00
|
|
|
* @return TRUE if it has MetaData
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-07-03 01:03:46 +00:00
|
|
|
*/
|
|
|
|
virtual UBool hasMetaData() const;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2000-05-20 04:41:12 +00:00
|
|
|
/**
|
|
|
|
* Copy a substring of this object, retaining attribute (out-of-band)
|
|
|
|
* information. This method is used to duplicate or reorder substrings.
|
|
|
|
* The destination index must not overlap the source range.
|
2004-08-24 17:21:14 +00:00
|
|
|
*
|
2000-05-20 04:41:12 +00:00
|
|
|
* @param start the beginning index, inclusive; <code>0 <= start <=
|
|
|
|
* limit</code>.
|
|
|
|
* @param limit the ending index, exclusive; <code>start <= limit <=
|
|
|
|
* length()</code>.
|
|
|
|
* @param dest the destination index. The characters from
|
|
|
|
* <code>start..limit-1</code> will be copied to <code>dest</code>.
|
|
|
|
* Implementations of this method may assume that <code>dest <= start ||
|
|
|
|
* dest >= limit</code>.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-05-20 04:41:12 +00:00
|
|
|
*/
|
|
|
|
virtual void copy(int32_t start, int32_t limit, int32_t dest);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/* Search and replace operations */
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Replace all occurrences of characters in oldText with the characters
|
1999-12-28 23:39:02 +00:00
|
|
|
* in newText
|
|
|
|
* @param oldText the text containing the search text
|
|
|
|
* @param newText the text containing the replacement text
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString& findAndReplace(const UnicodeString& oldText,
|
|
|
|
const UnicodeString& newText);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Replace all occurrences of characters in oldText with characters
|
1999-12-28 23:39:02 +00:00
|
|
|
* in newText
|
|
|
|
* in the range [<TT>start</TT>, <TT>start + length</TT>).
|
|
|
|
* @param start the start of the range in which replace will performed
|
|
|
|
* @param length the length of the range in which replace will be performed
|
|
|
|
* @param oldText the text containing the search text
|
|
|
|
* @param newText the text containing the replacement text
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline UnicodeString& findAndReplace(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length,
|
|
|
|
const UnicodeString& oldText,
|
|
|
|
const UnicodeString& newText);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Replace all occurrences of characters in oldText in the range
|
|
|
|
* [<TT>oldStart</TT>, <TT>oldStart + oldLength</TT>) with the characters
|
|
|
|
* in newText in the range
|
|
|
|
* [<TT>newStart</TT>, <TT>newStart + newLength</TT>)
|
1999-12-28 23:39:02 +00:00
|
|
|
* in the range [<TT>start</TT>, <TT>start + length</TT>).
|
|
|
|
* @param start the start of the range in which replace will performed
|
|
|
|
* @param length the length of the range in which replace will be performed
|
|
|
|
* @param oldText the text containing the search text
|
|
|
|
* @param oldStart the start of the search range in <TT>oldText</TT>
|
|
|
|
* @param oldLength the length of the search range in <TT>oldText</TT>
|
|
|
|
* @param newText the text containing the replacement text
|
|
|
|
* @param newStart the start of the replacement range in <TT>newText</TT>
|
|
|
|
* @param newLength the length of the replacement range in <TT>newText</TT>
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString& findAndReplace(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length,
|
|
|
|
const UnicodeString& oldText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t oldStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t oldLength,
|
|
|
|
const UnicodeString& newText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t newStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t newLength);
|
|
|
|
|
|
|
|
|
|
|
|
/* Remove operations */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove all characters from the UnicodeString object.
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString& remove(void);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Remove the characters in the range
|
1999-12-28 23:39:02 +00:00
|
|
|
* [<TT>start</TT>, <TT>start + length</TT>) from the UnicodeString object.
|
|
|
|
* @param start the offset of the first character to remove
|
|
|
|
* @param length the number of characters to remove
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString& remove(int32_t start,
|
2001-03-28 18:30:43 +00:00
|
|
|
int32_t length = (int32_t)INT32_MAX);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Remove the characters in the range
|
1999-12-28 23:39:02 +00:00
|
|
|
* [<TT>start</TT>, <TT>limit</TT>) from the UnicodeString object.
|
|
|
|
* @param start the offset of the first character to remove
|
|
|
|
* @param limit the offset immediately following the range to remove
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline UnicodeString& removeBetween(int32_t start,
|
|
|
|
int32_t limit = (int32_t)INT32_MAX);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2010-01-06 23:50:03 +00:00
|
|
|
/**
|
|
|
|
* Retain only the characters in the range
|
|
|
|
* [<code>start</code>, <code>limit</code>) from the UnicodeString object.
|
|
|
|
* Removes characters before <code>start</code> and at and after <code>limit</code>.
|
|
|
|
* @param start the offset of the first character to retain
|
|
|
|
* @param limit the offset immediately following the range to retain
|
|
|
|
* @return a reference to this
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-06 23:50:03 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString &retainBetween(int32_t start, int32_t limit = INT32_MAX);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/* Length operations */
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Pad the start of this UnicodeString with the character <TT>padChar</TT>.
|
|
|
|
* If the length of this UnicodeString is less than targetLength,
|
1999-12-28 23:39:02 +00:00
|
|
|
* length() - targetLength copies of padChar will be added to the
|
|
|
|
* beginning of this UnicodeString.
|
|
|
|
* @param targetLength the desired length of the string
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param padChar the character to use for padding. Defaults to
|
1999-12-28 23:39:02 +00:00
|
|
|
* space (U+0020)
|
|
|
|
* @return TRUE if the text was padded, FALSE otherwise.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool padLeading(int32_t targetLength,
|
2000-04-01 00:21:57 +00:00
|
|
|
UChar padChar = 0x0020);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Pad the end of this UnicodeString with the character <TT>padChar</TT>.
|
|
|
|
* If the length of this UnicodeString is less than targetLength,
|
1999-12-28 23:39:02 +00:00
|
|
|
* length() - targetLength copies of padChar will be added to the
|
|
|
|
* end of this UnicodeString.
|
|
|
|
* @param targetLength the desired length of the string
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param padChar the character to use for padding. Defaults to
|
1999-12-28 23:39:02 +00:00
|
|
|
* space (U+0020)
|
|
|
|
* @return TRUE if the text was padded, FALSE otherwise.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool padTrailing(int32_t targetLength,
|
2000-04-01 00:21:57 +00:00
|
|
|
UChar padChar = 0x0020);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Truncate this UnicodeString to the <TT>targetLength</TT>.
|
|
|
|
* @param targetLength the desired length of this UnicodeString.
|
|
|
|
* @return TRUE if the text was truncated, FALSE otherwise
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool truncate(int32_t targetLength);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Trims leading and trailing whitespace from this UnicodeString.
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-04-01 00:21:57 +00:00
|
|
|
UnicodeString& trim(void);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Miscellaneous operations */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse this UnicodeString in place.
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
inline UnicodeString& reverse(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the range [<TT>start</TT>, <TT>start + length</TT>) in
|
|
|
|
* this UnicodeString.
|
|
|
|
* @param start the start of the range to reverse
|
|
|
|
* @param length the number of characters to to reverse
|
|
|
|
* @return a reference to this
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
inline UnicodeString& reverse(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert the characters in this to UPPER CASE following the conventions of
|
|
|
|
* the default locale.
|
|
|
|
* @return A reference to this.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
UnicodeString& toUpper(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert the characters in this to UPPER CASE following the conventions of
|
|
|
|
* a specific locale.
|
|
|
|
* @param locale The locale containing the conventions to use.
|
|
|
|
* @return A reference to this.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
UnicodeString& toUpper(const Locale& locale);
|
|
|
|
|
|
|
|
/**
|
2001-02-14 01:10:10 +00:00
|
|
|
* Convert the characters in this to lower case following the conventions of
|
|
|
|
* the default locale.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return A reference to this.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
UnicodeString& toLower(void);
|
|
|
|
|
|
|
|
/**
|
2001-02-14 01:10:10 +00:00
|
|
|
* Convert the characters in this to lower case following the conventions of
|
1999-12-28 23:39:02 +00:00
|
|
|
* a specific locale.
|
|
|
|
* @param locale The locale containing the conventions to use.
|
|
|
|
* @return A reference to this.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
UnicodeString& toLower(const Locale& locale);
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#if !UCONFIG_NO_BREAK_ITERATION
|
|
|
|
|
2002-02-21 18:42:52 +00:00
|
|
|
/**
|
|
|
|
* Titlecase this string, convenience function using the default locale.
|
|
|
|
*
|
|
|
|
* Casing is locale-dependent and context-sensitive.
|
|
|
|
* Titlecasing uses a break iterator to find the first characters of words
|
|
|
|
* that are to be titlecased. It titlecases those characters and lowercases
|
|
|
|
* all others.
|
|
|
|
*
|
|
|
|
* The titlecase break iterator can be provided to customize for arbitrary
|
|
|
|
* styles, using rules and dictionaries beyond the standard iterators.
|
|
|
|
* It may be more efficient to always provide an iterator to avoid
|
|
|
|
* opening and closing one for each string.
|
|
|
|
* The standard titlecase iterator for the root locale implements the
|
|
|
|
* algorithm of Unicode TR 21.
|
|
|
|
*
|
2007-07-27 06:37:08 +00:00
|
|
|
* This function uses only the setText(), first() and next() methods of the
|
2002-02-22 00:14:54 +00:00
|
|
|
* provided break iterator.
|
|
|
|
*
|
2002-02-21 18:42:52 +00:00
|
|
|
* @param titleIter A break iterator to find the first characters of words
|
|
|
|
* that are to be titlecased.
|
|
|
|
* If none is provided (0), then a standard titlecase
|
|
|
|
* break iterator is opened.
|
2003-10-31 22:09:48 +00:00
|
|
|
* Otherwise the provided iterator is set to the string's text.
|
2002-02-21 18:42:52 +00:00
|
|
|
* @return A reference to this.
|
2003-06-04 00:04:35 +00:00
|
|
|
* @stable ICU 2.1
|
2002-02-21 18:42:52 +00:00
|
|
|
*/
|
|
|
|
UnicodeString &toTitle(BreakIterator *titleIter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Titlecase this string.
|
|
|
|
*
|
|
|
|
* Casing is locale-dependent and context-sensitive.
|
|
|
|
* Titlecasing uses a break iterator to find the first characters of words
|
|
|
|
* that are to be titlecased. It titlecases those characters and lowercases
|
|
|
|
* all others.
|
|
|
|
*
|
|
|
|
* The titlecase break iterator can be provided to customize for arbitrary
|
|
|
|
* styles, using rules and dictionaries beyond the standard iterators.
|
|
|
|
* It may be more efficient to always provide an iterator to avoid
|
|
|
|
* opening and closing one for each string.
|
|
|
|
* The standard titlecase iterator for the root locale implements the
|
|
|
|
* algorithm of Unicode TR 21.
|
|
|
|
*
|
2007-07-27 06:37:08 +00:00
|
|
|
* This function uses only the setText(), first() and next() methods of the
|
2002-02-22 00:14:54 +00:00
|
|
|
* provided break iterator.
|
|
|
|
*
|
2002-02-21 18:42:52 +00:00
|
|
|
* @param titleIter A break iterator to find the first characters of words
|
|
|
|
* that are to be titlecased.
|
|
|
|
* If none is provided (0), then a standard titlecase
|
|
|
|
* break iterator is opened.
|
2003-10-31 22:09:48 +00:00
|
|
|
* Otherwise the provided iterator is set to the string's text.
|
2002-02-21 18:42:52 +00:00
|
|
|
* @param locale The locale to consider.
|
|
|
|
* @return A reference to this.
|
2003-06-04 00:04:35 +00:00
|
|
|
* @stable ICU 2.1
|
2002-02-21 18:42:52 +00:00
|
|
|
*/
|
|
|
|
UnicodeString &toTitle(BreakIterator *titleIter, const Locale &locale);
|
|
|
|
|
2007-07-27 06:37:08 +00:00
|
|
|
/**
|
|
|
|
* Titlecase this string, with options.
|
|
|
|
*
|
|
|
|
* Casing is locale-dependent and context-sensitive.
|
|
|
|
* Titlecasing uses a break iterator to find the first characters of words
|
|
|
|
* that are to be titlecased. It titlecases those characters and lowercases
|
|
|
|
* all others. (This can be modified with options.)
|
|
|
|
*
|
|
|
|
* The titlecase break iterator can be provided to customize for arbitrary
|
|
|
|
* styles, using rules and dictionaries beyond the standard iterators.
|
|
|
|
* It may be more efficient to always provide an iterator to avoid
|
|
|
|
* opening and closing one for each string.
|
|
|
|
* The standard titlecase iterator for the root locale implements the
|
|
|
|
* algorithm of Unicode TR 21.
|
|
|
|
*
|
|
|
|
* This function uses only the setText(), first() and next() methods of the
|
|
|
|
* provided break iterator.
|
|
|
|
*
|
|
|
|
* @param titleIter A break iterator to find the first characters of words
|
|
|
|
* that are to be titlecased.
|
|
|
|
* If none is provided (0), then a standard titlecase
|
|
|
|
* break iterator is opened.
|
|
|
|
* Otherwise the provided iterator is set to the string's text.
|
|
|
|
* @param locale The locale to consider.
|
2007-08-03 23:52:19 +00:00
|
|
|
* @param options Options bit set, see ucasemap_open().
|
2007-07-27 06:37:08 +00:00
|
|
|
* @return A reference to this.
|
|
|
|
* @see U_TITLECASE_NO_LOWERCASE
|
|
|
|
* @see U_TITLECASE_NO_BREAK_ADJUSTMENT
|
2007-08-03 23:52:19 +00:00
|
|
|
* @see ucasemap_open
|
2008-07-21 18:57:26 +00:00
|
|
|
* @stable ICU 3.8
|
2007-07-27 06:37:08 +00:00
|
|
|
*/
|
|
|
|
UnicodeString &toTitle(BreakIterator *titleIter, const Locale &locale, uint32_t options);
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#endif
|
|
|
|
|
2001-02-14 01:10:10 +00:00
|
|
|
/**
|
2012-08-27 23:42:11 +00:00
|
|
|
* Case-folds the characters in this string.
|
|
|
|
*
|
2001-02-14 01:10:10 +00:00
|
|
|
* Case-folding is locale-independent and not context-sensitive,
|
|
|
|
* but there is an option for whether to include or exclude mappings for dotted I
|
2012-08-27 23:42:11 +00:00
|
|
|
* and dotless i that are marked with 'T' in CaseFolding.txt.
|
|
|
|
*
|
2001-02-14 01:10:10 +00:00
|
|
|
* The result may be longer or shorter than the original.
|
|
|
|
*
|
|
|
|
* @param options Either U_FOLD_CASE_DEFAULT or U_FOLD_CASE_EXCLUDE_SPECIAL_I
|
|
|
|
* @return A reference to this.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-02-14 01:10:10 +00:00
|
|
|
*/
|
2001-11-30 00:06:13 +00:00
|
|
|
UnicodeString &foldCase(uint32_t options=0 /*U_FOLD_CASE_DEFAULT*/);
|
2001-02-14 01:10:10 +00:00
|
|
|
|
2001-09-20 01:14:37 +00:00
|
|
|
//========================================
|
|
|
|
// Access to the internal buffer
|
|
|
|
//========================================
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a read/write pointer to the internal buffer.
|
|
|
|
* The buffer is guaranteed to be large enough for at least minCapacity UChars,
|
|
|
|
* writable, and is still owned by the UnicodeString object.
|
|
|
|
* Calls to getBuffer(minCapacity) must not be nested, and
|
|
|
|
* must be matched with calls to releaseBuffer(newLength).
|
|
|
|
* If the string buffer was read-only or shared,
|
|
|
|
* then it will be reallocated and copied.
|
|
|
|
*
|
|
|
|
* An attempted nested call will return 0, and will not further modify the
|
|
|
|
* state of the UnicodeString object.
|
2002-11-16 01:05:36 +00:00
|
|
|
* It also returns 0 if the string is bogus.
|
2001-09-20 01:14:37 +00:00
|
|
|
*
|
2001-10-05 20:44:56 +00:00
|
|
|
* The actual capacity of the string buffer may be larger than minCapacity.
|
|
|
|
* getCapacity() returns the actual capacity.
|
|
|
|
* For many operations, the full capacity should be used to avoid reallocations.
|
|
|
|
*
|
2001-09-20 01:14:37 +00:00
|
|
|
* While the buffer is "open" between getBuffer(minCapacity)
|
|
|
|
* and releaseBuffer(newLength), the following applies:
|
|
|
|
* - The string length is set to 0.
|
|
|
|
* - Any read API call on the UnicodeString object will behave like on a 0-length string.
|
|
|
|
* - Any write API call on the UnicodeString object is disallowed and will have no effect.
|
|
|
|
* - You can read from and write to the returned buffer.
|
|
|
|
* - The previous string contents will still be in the buffer;
|
|
|
|
* if you want to use it, then you need to call length() before getBuffer(minCapacity).
|
|
|
|
* If the length() was greater than minCapacity, then any contents after minCapacity
|
|
|
|
* may be lost.
|
|
|
|
* The buffer contents is not NUL-terminated by getBuffer().
|
2002-06-08 19:35:15 +00:00
|
|
|
* If length()<getCapacity() then you can terminate it by writing a NUL
|
|
|
|
* at index length().
|
2001-09-20 01:14:37 +00:00
|
|
|
* - You must call releaseBuffer(newLength) before and in order to
|
|
|
|
* return to normal UnicodeString operation.
|
|
|
|
*
|
|
|
|
* @param minCapacity the minimum number of UChars that are to be available
|
|
|
|
* in the buffer, starting at the returned pointer;
|
|
|
|
* default to the current string capacity if minCapacity==-1
|
|
|
|
* @return a writable pointer to the internal string buffer,
|
|
|
|
* or 0 if an error occurs (nested calls, out of memory)
|
|
|
|
*
|
|
|
|
* @see releaseBuffer
|
2002-06-08 19:35:15 +00:00
|
|
|
* @see getTerminatedBuffer()
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-09-20 01:14:37 +00:00
|
|
|
*/
|
|
|
|
UChar *getBuffer(int32_t minCapacity);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Release a read/write buffer on a UnicodeString object with an
|
|
|
|
* "open" getBuffer(minCapacity).
|
|
|
|
* This function must be called in a matched pair with getBuffer(minCapacity).
|
|
|
|
* releaseBuffer(newLength) must be called if and only if a getBuffer(minCapacity) is "open".
|
|
|
|
*
|
|
|
|
* It will set the string length to newLength, at most to the current capacity.
|
|
|
|
* If newLength==-1 then it will set the length according to the
|
|
|
|
* first NUL in the buffer, or to the capacity if there is no NUL.
|
|
|
|
*
|
|
|
|
* After calling releaseBuffer(newLength) the UnicodeString is back to normal operation.
|
|
|
|
*
|
|
|
|
* @param newLength the new length of the UnicodeString object;
|
|
|
|
* defaults to the current capacity if newLength is greater than that;
|
|
|
|
* if newLength==-1, it defaults to u_strlen(buffer) but not more than
|
|
|
|
* the current capacity of the string
|
|
|
|
*
|
|
|
|
* @see getBuffer(int32_t minCapacity)
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-09-20 01:14:37 +00:00
|
|
|
*/
|
|
|
|
void releaseBuffer(int32_t newLength=-1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a read-only pointer to the internal buffer.
|
|
|
|
* This can be called at any time on a valid UnicodeString.
|
|
|
|
*
|
2001-09-22 00:58:52 +00:00
|
|
|
* It returns 0 if the string is bogus, or
|
|
|
|
* during an "open" getBuffer(minCapacity).
|
2001-09-20 01:14:37 +00:00
|
|
|
*
|
|
|
|
* It can be called as many times as desired.
|
|
|
|
* The pointer that it returns will remain valid until the UnicodeString object is modified,
|
|
|
|
* at which time the pointer is semantically invalidated and must not be used any more.
|
|
|
|
*
|
2001-10-05 20:44:56 +00:00
|
|
|
* The capacity of the buffer can be determined with getCapacity().
|
|
|
|
* The part after length() may or may not be initialized and valid,
|
|
|
|
* depending on the history of the UnicodeString object.
|
|
|
|
*
|
|
|
|
* The buffer contents is (probably) not NUL-terminated.
|
|
|
|
* You can check if it is with
|
|
|
|
* <code>(s.length()<s.getCapacity() && buffer[s.length()]==0)</code>.
|
2002-06-08 19:35:15 +00:00
|
|
|
* (See getTerminatedBuffer().)
|
2001-10-05 20:44:56 +00:00
|
|
|
*
|
|
|
|
* The buffer may reside in read-only memory. Its contents must not
|
|
|
|
* be modified.
|
2001-09-20 01:14:37 +00:00
|
|
|
*
|
|
|
|
* @return a read-only pointer to the internal string buffer,
|
|
|
|
* or 0 if the string is empty or bogus
|
|
|
|
*
|
|
|
|
* @see getBuffer(int32_t minCapacity)
|
2002-06-08 19:35:15 +00:00
|
|
|
* @see getTerminatedBuffer()
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-09-20 01:14:37 +00:00
|
|
|
*/
|
|
|
|
inline const UChar *getBuffer() const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2002-06-08 19:35:15 +00:00
|
|
|
/**
|
|
|
|
* Get a read-only pointer to the internal buffer,
|
|
|
|
* making sure that it is NUL-terminated.
|
|
|
|
* This can be called at any time on a valid UnicodeString.
|
|
|
|
*
|
|
|
|
* It returns 0 if the string is bogus, or
|
|
|
|
* during an "open" getBuffer(minCapacity), or if the buffer cannot
|
|
|
|
* be NUL-terminated (because memory allocation failed).
|
|
|
|
*
|
|
|
|
* It can be called as many times as desired.
|
|
|
|
* The pointer that it returns will remain valid until the UnicodeString object is modified,
|
|
|
|
* at which time the pointer is semantically invalidated and must not be used any more.
|
|
|
|
*
|
|
|
|
* The capacity of the buffer can be determined with getCapacity().
|
|
|
|
* The part after length()+1 may or may not be initialized and valid,
|
|
|
|
* depending on the history of the UnicodeString object.
|
|
|
|
*
|
|
|
|
* The buffer contents is guaranteed to be NUL-terminated.
|
|
|
|
* getTerminatedBuffer() may reallocate the buffer if a terminating NUL
|
|
|
|
* is written.
|
|
|
|
* For this reason, this function is not const, unlike getBuffer().
|
|
|
|
* Note that a UnicodeString may also contain NUL characters as part of its contents.
|
|
|
|
*
|
|
|
|
* The buffer may reside in read-only memory. Its contents must not
|
|
|
|
* be modified.
|
|
|
|
*
|
|
|
|
* @return a read-only pointer to the internal string buffer,
|
|
|
|
* or 0 if the string is empty or bogus
|
|
|
|
*
|
|
|
|
* @see getBuffer(int32_t minCapacity)
|
|
|
|
* @see getBuffer()
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-06-08 19:35:15 +00:00
|
|
|
*/
|
|
|
|
inline const UChar *getTerminatedBuffer();
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
//========================================
|
|
|
|
// Constructors
|
|
|
|
//========================================
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
/** Construct an empty UnicodeString.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct a UnicodeString with capacity to hold <TT>capacity</TT> UChars
|
|
|
|
* @param capacity the number of UChars this UnicodeString should hold
|
2000-04-19 20:27:00 +00:00
|
|
|
* before a resize is necessary; if count is greater than 0 and count
|
|
|
|
* code points c take up more space than capacity, then capacity is adjusted
|
|
|
|
* accordingly.
|
|
|
|
* @param c is used to initially fill the string
|
|
|
|
* @param count specifies how many code points c are to be written in the
|
|
|
|
* string
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-04-19 20:27:00 +00:00
|
|
|
UnicodeString(int32_t capacity, UChar32 c, int32_t count);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-04-01 00:21:57 +00:00
|
|
|
* Single UChar (code unit) constructor.
|
2011-07-07 18:46:19 +00:00
|
|
|
*
|
|
|
|
* It is recommended to mark this constructor "explicit" by
|
|
|
|
* <code>-DUNISTR_FROM_CHAR_EXPLICIT=explicit</code>
|
|
|
|
* on the compiler command line or similar.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param ch the character to place in the UnicodeString
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2011-07-07 18:46:19 +00:00
|
|
|
UNISTR_FROM_CHAR_EXPLICIT UnicodeString(UChar ch);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-04-01 00:21:57 +00:00
|
|
|
/**
|
|
|
|
* Single UChar32 (code point) constructor.
|
2011-07-07 18:46:19 +00:00
|
|
|
*
|
|
|
|
* It is recommended to mark this constructor "explicit" by
|
|
|
|
* <code>-DUNISTR_FROM_CHAR_EXPLICIT=explicit</code>
|
|
|
|
* on the compiler command line or similar.
|
2000-04-01 00:21:57 +00:00
|
|
|
* @param ch the character to place in the UnicodeString
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-04-01 00:21:57 +00:00
|
|
|
*/
|
2011-07-07 18:46:19 +00:00
|
|
|
UNISTR_FROM_CHAR_EXPLICIT UnicodeString(UChar32 ch);
|
2000-04-01 00:21:57 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* UChar* constructor.
|
2011-07-07 18:46:19 +00:00
|
|
|
*
|
|
|
|
* It is recommended to mark this constructor "explicit" by
|
|
|
|
* <code>-DUNISTR_FROM_STRING_EXPLICIT=explicit</code>
|
|
|
|
* on the compiler command line or similar.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param text The characters to place in the UnicodeString. <TT>text</TT>
|
|
|
|
* must be NULL (U+0000) terminated.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2011-07-07 18:46:19 +00:00
|
|
|
UNISTR_FROM_STRING_EXPLICIT UnicodeString(const UChar *text);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* UChar* constructor.
|
|
|
|
* @param text The characters to place in the UnicodeString.
|
|
|
|
* @param textLength The number of Unicode characters in <TT>text</TT>
|
|
|
|
* to copy.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
UnicodeString(const UChar *text,
|
|
|
|
int32_t textLength);
|
|
|
|
|
|
|
|
/**
|
2000-03-29 01:13:49 +00:00
|
|
|
* Readonly-aliasing UChar* constructor.
|
|
|
|
* The text will be used for the UnicodeString object, but
|
1999-12-28 23:39:02 +00:00
|
|
|
* it will not be released when the UnicodeString is destroyed.
|
2000-03-29 01:13:49 +00:00
|
|
|
* This has copy-on-write semantics:
|
|
|
|
* When the string is modified, then the buffer is first copied into
|
|
|
|
* newly allocated memory.
|
|
|
|
* The aliased buffer is never modified.
|
2012-06-06 17:35:12 +00:00
|
|
|
*
|
|
|
|
* In an assignment to another UnicodeString, when using the copy constructor
|
|
|
|
* or the assignment operator, the text will be copied.
|
|
|
|
* When using fastCopyFrom(), the text will be aliased again,
|
2000-03-29 01:13:49 +00:00
|
|
|
* so that both strings then alias the same readonly-text.
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
|
|
|
* @param isTerminated specifies if <code>text</code> is <code>NUL</code>-terminated.
|
|
|
|
* This must be true if <code>textLength==-1</code>.
|
|
|
|
* @param text The characters to alias for the UnicodeString.
|
|
|
|
* @param textLength The number of Unicode characters in <code>text</code> to alias.
|
|
|
|
* If -1, then this constructor will determine the length
|
|
|
|
* by calling <code>u_strlen()</code>.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
UnicodeString(UBool isTerminated,
|
2000-04-03 23:53:59 +00:00
|
|
|
const UChar *text,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t textLength);
|
|
|
|
|
2000-03-29 01:13:49 +00:00
|
|
|
/**
|
2001-09-20 01:14:37 +00:00
|
|
|
* Writable-aliasing UChar* constructor.
|
2000-03-29 01:13:49 +00:00
|
|
|
* The text will be used for the UnicodeString object, but
|
|
|
|
* it will not be released when the UnicodeString is destroyed.
|
|
|
|
* This has write-through semantics:
|
|
|
|
* For as long as the capacity of the buffer is sufficient, write operations
|
|
|
|
* will directly affect the buffer. When more capacity is necessary, then
|
|
|
|
* a new buffer will be allocated and the contents copied as with regularly
|
|
|
|
* constructed strings.
|
|
|
|
* In an assignment to another UnicodeString, the buffer will be copied.
|
|
|
|
* The extract(UChar *dst) function detects whether the dst pointer is the same
|
|
|
|
* as the string buffer itself and will in this case not copy the contents.
|
|
|
|
*
|
|
|
|
* @param buffer The characters to alias for the UnicodeString.
|
|
|
|
* @param buffLength The number of Unicode characters in <code>buffer</code> to alias.
|
|
|
|
* @param buffCapacity The size of <code>buffer</code> in UChars.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-29 01:13:49 +00:00
|
|
|
*/
|
|
|
|
UnicodeString(UChar *buffer, int32_t buffLength, int32_t buffCapacity);
|
|
|
|
|
2009-03-11 23:57:47 +00:00
|
|
|
#if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION
|
|
|
|
|
|
|
|
/**
|
|
|
|
* char* constructor.
|
2011-07-07 18:46:19 +00:00
|
|
|
* Uses the default converter (and thus depends on the ICU conversion code)
|
|
|
|
* unless U_CHARSET_IS_UTF8 is set to 1.
|
|
|
|
*
|
2011-07-08 22:09:28 +00:00
|
|
|
* For ASCII (really "invariant character") strings it is more efficient to use
|
|
|
|
* the constructor that takes a US_INV (for its enum EInvariant).
|
|
|
|
* For ASCII (invariant-character) string literals, see UNICODE_STRING and
|
|
|
|
* UNICODE_STRING_SIMPLE.
|
|
|
|
*
|
2011-07-07 18:46:19 +00:00
|
|
|
* It is recommended to mark this constructor "explicit" by
|
|
|
|
* <code>-DUNISTR_FROM_STRING_EXPLICIT=explicit</code>
|
|
|
|
* on the compiler command line or similar.
|
2009-03-11 23:57:47 +00:00
|
|
|
* @param codepageData an array of bytes, null-terminated,
|
|
|
|
* in the platform's default codepage.
|
|
|
|
* @stable ICU 2.0
|
2011-07-08 22:09:28 +00:00
|
|
|
* @see UNICODE_STRING
|
|
|
|
* @see UNICODE_STRING_SIMPLE
|
2009-03-11 23:57:47 +00:00
|
|
|
*/
|
2011-07-07 18:46:19 +00:00
|
|
|
UNISTR_FROM_STRING_EXPLICIT UnicodeString(const char *codepageData);
|
2009-03-11 23:57:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* char* constructor.
|
2011-07-07 18:46:19 +00:00
|
|
|
* Uses the default converter (and thus depends on the ICU conversion code)
|
|
|
|
* unless U_CHARSET_IS_UTF8 is set to 1.
|
2009-03-11 23:57:47 +00:00
|
|
|
* @param codepageData an array of bytes in the platform's default codepage.
|
|
|
|
* @param dataLength The number of bytes in <TT>codepageData</TT>.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
UnicodeString(const char *codepageData, int32_t dataLength);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2004-08-26 22:58:39 +00:00
|
|
|
#if !UCONFIG_NO_CONVERSION
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* char* constructor.
|
|
|
|
* @param codepageData an array of bytes, null-terminated
|
|
|
|
* @param codepage the encoding of <TT>codepageData</TT>. The special
|
2004-08-24 17:21:14 +00:00
|
|
|
* value 0 for <TT>codepage</TT> indicates that the text is in the
|
1999-12-28 23:39:02 +00:00
|
|
|
* platform's default codepage.
|
2004-08-26 22:58:39 +00:00
|
|
|
*
|
1999-12-28 23:39:02 +00:00
|
|
|
* If <code>codepage</code> is an empty string (<code>""</code>),
|
|
|
|
* then a simple conversion is performed on the codepage-invariant
|
|
|
|
* subset ("invariant characters") of the platform encoding. See utypes.h.
|
2004-08-26 22:58:39 +00:00
|
|
|
* Recommendation: For invariant-character strings use the constructor
|
|
|
|
* UnicodeString(const char *src, int32_t length, enum EInvariant inv)
|
|
|
|
* because it avoids object code dependencies of UnicodeString on
|
|
|
|
* the conversion code.
|
|
|
|
*
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2009-03-11 23:57:47 +00:00
|
|
|
UnicodeString(const char *codepageData, const char *codepage);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* char* constructor.
|
|
|
|
* @param codepageData an array of bytes.
|
|
|
|
* @param dataLength The number of bytes in <TT>codepageData</TT>.
|
|
|
|
* @param codepage the encoding of <TT>codepageData</TT>. The special
|
2004-08-24 17:21:14 +00:00
|
|
|
* value 0 for <TT>codepage</TT> indicates that the text is in the
|
1999-12-28 23:39:02 +00:00
|
|
|
* platform's default codepage.
|
|
|
|
* If <code>codepage</code> is an empty string (<code>""</code>),
|
|
|
|
* then a simple conversion is performed on the codepage-invariant
|
|
|
|
* subset ("invariant characters") of the platform encoding. See utypes.h.
|
2004-08-26 22:58:39 +00:00
|
|
|
* Recommendation: For invariant-character strings use the constructor
|
|
|
|
* UnicodeString(const char *src, int32_t length, enum EInvariant inv)
|
|
|
|
* because it avoids object code dependencies of UnicodeString on
|
|
|
|
* the conversion code.
|
|
|
|
*
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2009-03-11 23:57:47 +00:00
|
|
|
UnicodeString(const char *codepageData, int32_t dataLength, const char *codepage);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2001-09-18 01:12:14 +00:00
|
|
|
/**
|
|
|
|
* char * / UConverter constructor.
|
|
|
|
* This constructor uses an existing UConverter object to
|
|
|
|
* convert the codepage string to Unicode and construct a UnicodeString
|
|
|
|
* from that.
|
|
|
|
*
|
|
|
|
* The converter is reset at first.
|
|
|
|
* If the error code indicates a failure before this constructor is called,
|
|
|
|
* or if an error occurs during conversion or construction,
|
|
|
|
* then the string will be bogus.
|
|
|
|
*
|
|
|
|
* This function avoids the overhead of opening and closing a converter if
|
|
|
|
* multiple strings are constructed.
|
|
|
|
*
|
|
|
|
* @param src input codepage string
|
|
|
|
* @param srcLength length of the input string, can be -1 for NUL-terminated strings
|
|
|
|
* @param cnv converter object (ucnv_resetToUnicode() will be called),
|
|
|
|
* can be NULL for the default converter
|
|
|
|
* @param errorCode normal ICU error code
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-09-18 01:12:14 +00:00
|
|
|
*/
|
|
|
|
UnicodeString(
|
|
|
|
const char *src, int32_t srcLength,
|
|
|
|
UConverter *cnv,
|
|
|
|
UErrorCode &errorCode);
|
|
|
|
|
2004-08-26 22:58:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a Unicode string from an invariant-character char * string.
|
|
|
|
* About invariant characters see utypes.h.
|
|
|
|
* This constructor has no runtime dependency on conversion code and is
|
|
|
|
* therefore recommended over ones taking a charset name string
|
|
|
|
* (where the empty string "" indicates invariant-character conversion).
|
|
|
|
*
|
|
|
|
* Use the macro US_INV as the third, signature-distinguishing parameter.
|
|
|
|
*
|
|
|
|
* For example:
|
|
|
|
* \code
|
|
|
|
* void fn(const char *s) {
|
|
|
|
* UnicodeString ustr(s, -1, US_INV);
|
|
|
|
* // use ustr ...
|
|
|
|
* }
|
|
|
|
* \endcode
|
|
|
|
*
|
|
|
|
* @param src String using only invariant characters.
|
|
|
|
* @param length Length of src, or -1 if NUL-terminated.
|
|
|
|
* @param inv Signature-distinguishing paramater, use US_INV.
|
|
|
|
*
|
|
|
|
* @see US_INV
|
2006-01-18 03:34:19 +00:00
|
|
|
* @stable ICU 3.2
|
2004-08-26 22:58:39 +00:00
|
|
|
*/
|
|
|
|
UnicodeString(const char *src, int32_t length, enum EInvariant inv);
|
|
|
|
|
2001-09-18 01:12:14 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Copy constructor.
|
|
|
|
* @param that The UnicodeString object to copy.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-03-29 01:13:49 +00:00
|
|
|
UnicodeString(const UnicodeString& that);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2002-04-26 18:02:49 +00:00
|
|
|
/**
|
|
|
|
* 'Substring' constructor from tail of source string.
|
|
|
|
* @param src The UnicodeString object to copy.
|
|
|
|
* @param srcStart The offset into <tt>src</tt> at which to start copying.
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-04-26 18:02:49 +00:00
|
|
|
*/
|
|
|
|
UnicodeString(const UnicodeString& src, int32_t srcStart);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 'Substring' constructor from subrange of source string.
|
|
|
|
* @param src The UnicodeString object to copy.
|
|
|
|
* @param srcStart The offset into <tt>src</tt> at which to start copying.
|
|
|
|
* @param srcLength The number of characters from <tt>src</tt> to copy.
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-04-26 18:02:49 +00:00
|
|
|
*/
|
|
|
|
UnicodeString(const UnicodeString& src, int32_t srcStart, int32_t srcLength);
|
|
|
|
|
2003-04-30 22:08:57 +00:00
|
|
|
/**
|
|
|
|
* Clone this object, an instance of a subclass of Replaceable.
|
|
|
|
* Clones can be used concurrently in multiple threads.
|
|
|
|
* If a subclass does not implement clone(), or if an error occurs,
|
|
|
|
* then NULL is returned.
|
|
|
|
* The clone functions in all subclasses return a pointer to a Replaceable
|
|
|
|
* because some compilers do not support covariant (same-as-this)
|
|
|
|
* return types; cast to the appropriate subclass if necessary.
|
|
|
|
* The caller must delete the clone.
|
|
|
|
*
|
|
|
|
* @return a clone of this object
|
|
|
|
*
|
|
|
|
* @see Replaceable::clone
|
|
|
|
* @see getDynamicClassID
|
2004-11-02 07:28:07 +00:00
|
|
|
* @stable ICU 2.6
|
2003-04-30 22:08:57 +00:00
|
|
|
*/
|
|
|
|
virtual Replaceable *clone() const;
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
/** Destructor.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2003-04-30 22:08:57 +00:00
|
|
|
*/
|
2004-06-30 05:36:17 +00:00
|
|
|
virtual ~UnicodeString();
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2009-03-06 19:19:00 +00:00
|
|
|
/**
|
|
|
|
* Create a UnicodeString from a UTF-8 string.
|
|
|
|
* Illegal input is replaced with U+FFFD. Otherwise, errors result in a bogus string.
|
|
|
|
* Calls u_strFromUTF8WithSub().
|
|
|
|
*
|
|
|
|
* @param utf8 UTF-8 input string.
|
|
|
|
* Note that a StringPiece can be implicitly constructed
|
|
|
|
* from a std::string or a NUL-terminated const char * string.
|
|
|
|
* @return A UnicodeString with equivalent UTF-16 contents.
|
|
|
|
* @see toUTF8
|
|
|
|
* @see toUTF8String
|
2010-01-28 21:09:53 +00:00
|
|
|
* @stable ICU 4.2
|
2009-03-06 19:19:00 +00:00
|
|
|
*/
|
|
|
|
static UnicodeString fromUTF8(const StringPiece &utf8);
|
|
|
|
|
2009-02-19 22:35:06 +00:00
|
|
|
/**
|
|
|
|
* Create a UnicodeString from a UTF-32 string.
|
|
|
|
* Illegal input is replaced with U+FFFD. Otherwise, errors result in a bogus string.
|
|
|
|
* Calls u_strFromUTF32WithSub().
|
|
|
|
*
|
|
|
|
* @param utf32 UTF-32 input string. Must not be NULL.
|
|
|
|
* @param length Length of the input string, or -1 if NUL-terminated.
|
|
|
|
* @return A UnicodeString with equivalent UTF-16 contents.
|
|
|
|
* @see toUTF32
|
2010-01-28 21:09:53 +00:00
|
|
|
* @stable ICU 4.2
|
2009-02-19 22:35:06 +00:00
|
|
|
*/
|
|
|
|
static UnicodeString fromUTF32(const UChar32 *utf32, int32_t length);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/* Miscellaneous operations */
|
|
|
|
|
2000-07-16 13:39:07 +00:00
|
|
|
/**
|
|
|
|
* Unescape a string of characters and return a string containing
|
|
|
|
* the result. The following escape sequences are recognized:
|
|
|
|
*
|
2004-06-15 20:52:22 +00:00
|
|
|
* \\uhhhh 4 hex digits; h in [0-9A-Fa-f]
|
|
|
|
* \\Uhhhhhhhh 8 hex digits
|
|
|
|
* \\xhh 1-2 hex digits
|
|
|
|
* \\ooo 1-3 octal digits; o in [0-7]
|
|
|
|
* \\cX control-X; X is masked with 0x1F
|
2000-07-16 13:39:07 +00:00
|
|
|
*
|
|
|
|
* as well as the standard ANSI C escapes:
|
|
|
|
*
|
2004-06-15 20:52:22 +00:00
|
|
|
* \\a => U+0007, \\b => U+0008, \\t => U+0009, \\n => U+000A,
|
|
|
|
* \\v => U+000B, \\f => U+000C, \\r => U+000D, \\e => U+001B,
|
2010-02-11 00:53:57 +00:00
|
|
|
* \\" => U+0022, \\' => U+0027, \\? => U+003F, \\\\ => U+005C
|
2000-07-16 13:39:07 +00:00
|
|
|
*
|
|
|
|
* Anything else following a backslash is generically escaped. For
|
2004-06-15 20:52:22 +00:00
|
|
|
* example, "[a\\-z]" returns "[a-z]".
|
2000-07-16 13:39:07 +00:00
|
|
|
*
|
|
|
|
* If an escape sequence is ill-formed, this method returns an empty
|
2004-06-15 20:52:22 +00:00
|
|
|
* string. An example of an ill-formed sequence is "\\u" followed by
|
2000-07-16 13:39:07 +00:00
|
|
|
* fewer than 4 hex digits.
|
|
|
|
*
|
|
|
|
* This function is similar to u_unescape() but not identical to it.
|
|
|
|
* The latter takes a source char*, so it does escape recognition
|
2000-07-16 13:49:24 +00:00
|
|
|
* and also invariant conversion.
|
2000-07-16 13:39:07 +00:00
|
|
|
*
|
|
|
|
* @return a string with backslash escapes interpreted, or an
|
|
|
|
* empty string on error.
|
2000-07-16 13:49:24 +00:00
|
|
|
* @see UnicodeString#unescapeAt()
|
2000-07-16 13:39:07 +00:00
|
|
|
* @see u_unescape()
|
2000-07-16 13:49:24 +00:00
|
|
|
* @see u_unescapeAt()
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-07-16 13:39:07 +00:00
|
|
|
*/
|
|
|
|
UnicodeString unescape() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unescape a single escape sequence and return the represented
|
|
|
|
* character. See unescape() for a listing of the recognized escape
|
|
|
|
* sequences. The character at offset-1 is assumed (without
|
|
|
|
* checking) to be a backslash. If the escape sequence is
|
2000-07-16 13:49:24 +00:00
|
|
|
* ill-formed, or the offset is out of range, (UChar32)0xFFFFFFFF is
|
|
|
|
* returned.
|
2000-07-16 13:39:07 +00:00
|
|
|
*
|
|
|
|
* @param offset an input output parameter. On input, it is the
|
|
|
|
* offset into this string where the escape sequence is located,
|
|
|
|
* after the initial backslash. On output, it is advanced after the
|
|
|
|
* last character parsed. On error, it is not advanced at all.
|
|
|
|
* @return the character represented by the escape sequence at
|
|
|
|
* offset, or (UChar32)0xFFFFFFFF on error.
|
2000-07-16 13:49:24 +00:00
|
|
|
* @see UnicodeString#unescape()
|
2000-07-16 13:39:07 +00:00
|
|
|
* @see u_unescape()
|
2000-07-16 13:49:24 +00:00
|
|
|
* @see u_unescapeAt()
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-07-16 13:39:07 +00:00
|
|
|
*/
|
|
|
|
UChar32 unescapeAt(int32_t &offset) const;
|
|
|
|
|
2002-06-29 00:04:16 +00:00
|
|
|
/**
|
2003-08-27 01:01:42 +00:00
|
|
|
* ICU "poor man's RTTI", returns a UClassID for this class.
|
2002-06-29 00:04:16 +00:00
|
|
|
*
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-06-29 00:04:16 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static UClassID U_EXPORT2 getStaticClassID();
|
2002-06-29 00:04:16 +00:00
|
|
|
|
|
|
|
/**
|
2003-08-27 01:01:42 +00:00
|
|
|
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
2002-06-29 00:04:16 +00:00
|
|
|
*
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-06-29 00:04:16 +00:00
|
|
|
*/
|
2003-08-27 01:01:42 +00:00
|
|
|
virtual UClassID getDynamicClassID() const;
|
2002-06-29 00:04:16 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
//========================================
|
|
|
|
// Implementation methods
|
|
|
|
//========================================
|
2001-01-02 19:37:08 +00:00
|
|
|
|
2001-02-14 18:02:44 +00:00
|
|
|
protected:
|
2001-07-02 20:58:14 +00:00
|
|
|
/**
|
|
|
|
* Implement Replaceable::getLength() (see jitterbug 1027).
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2001-07-02 20:58:14 +00:00
|
|
|
*/
|
|
|
|
virtual int32_t getLength() const;
|
|
|
|
|
2001-02-14 18:02:44 +00:00
|
|
|
/**
|
|
|
|
* The change in Replaceable to use virtual getCharAt() allows
|
|
|
|
* UnicodeString::charAt() to be inline again (see jitterbug 709).
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2001-02-14 18:02:44 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
virtual UChar getCharAt(int32_t offset) const;
|
2001-02-14 18:02:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The change in Replaceable to use virtual getChar32At() allows
|
|
|
|
* UnicodeString::char32At() to be inline again (see jitterbug 709).
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2001-02-14 18:02:44 +00:00
|
|
|
*/
|
2002-03-12 01:32:42 +00:00
|
|
|
virtual UChar32 getChar32At(int32_t offset) const;
|
2001-02-14 18:02:44 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
private:
|
2009-03-12 21:24:54 +00:00
|
|
|
// For char* constructors. Could be made public.
|
|
|
|
UnicodeString &setToUTF8(const StringPiece &utf8);
|
|
|
|
// For extract(char*).
|
|
|
|
// We could make a toUTF8(target, capacity, errorCode) public but not
|
|
|
|
// this version: New API will be cleaner if we make callers create substrings
|
|
|
|
// rather than having start+length on every method,
|
|
|
|
// and it should take a UErrorCode&.
|
|
|
|
int32_t
|
|
|
|
toUTF8(int32_t start, int32_t len,
|
|
|
|
char *target, int32_t capacity) const;
|
|
|
|
|
2012-10-08 18:24:41 +00:00
|
|
|
/**
|
|
|
|
* Internal string contents comparison, called by operator==.
|
|
|
|
* Requires: this & text not bogus and have same lengths.
|
|
|
|
*/
|
|
|
|
UBool doEquals(const UnicodeString &text, int32_t len) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
doCompare(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length,
|
|
|
|
const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength) const;
|
2001-01-02 19:37:08 +00:00
|
|
|
|
2002-03-12 01:32:42 +00:00
|
|
|
int8_t doCompare(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length,
|
|
|
|
const UChar *srcChars,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength) const;
|
|
|
|
|
2001-01-24 02:37:58 +00:00
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
doCompareCodePointOrder(int32_t start,
|
2001-01-24 02:37:58 +00:00
|
|
|
int32_t length,
|
|
|
|
const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2001-01-24 02:37:58 +00:00
|
|
|
int32_t srcLength) const;
|
|
|
|
|
2002-03-12 01:32:42 +00:00
|
|
|
int8_t doCompareCodePointOrder(int32_t start,
|
2001-01-24 02:37:58 +00:00
|
|
|
int32_t length,
|
|
|
|
const UChar *srcChars,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2001-01-24 02:37:58 +00:00
|
|
|
int32_t srcLength) const;
|
|
|
|
|
2001-02-14 01:10:10 +00:00
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
doCaseCompare(int32_t start,
|
2001-02-14 01:10:10 +00:00
|
|
|
int32_t length,
|
|
|
|
const UnicodeString &srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2001-02-14 01:10:10 +00:00
|
|
|
int32_t srcLength,
|
|
|
|
uint32_t options) const;
|
|
|
|
|
|
|
|
int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
doCaseCompare(int32_t start,
|
2001-02-14 01:10:10 +00:00
|
|
|
int32_t length,
|
|
|
|
const UChar *srcChars,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2001-02-14 01:10:10 +00:00
|
|
|
int32_t srcLength,
|
|
|
|
uint32_t options) const;
|
|
|
|
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t doIndexOf(UChar c,
|
|
|
|
int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t doIndexOf(UChar32 c,
|
|
|
|
int32_t start,
|
2002-02-22 02:00:42 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t doLastIndexOf(UChar c,
|
|
|
|
int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t doLastIndexOf(UChar32 c,
|
|
|
|
int32_t start,
|
2002-02-22 02:00:42 +00:00
|
|
|
int32_t length) const;
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
void doExtract(int32_t start,
|
|
|
|
int32_t length,
|
|
|
|
UChar *dst,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t dstStart) const;
|
2001-01-02 19:37:08 +00:00
|
|
|
|
2002-03-12 01:32:42 +00:00
|
|
|
inline void doExtract(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length,
|
|
|
|
UnicodeString& target) const;
|
2001-01-02 19:37:08 +00:00
|
|
|
|
2002-03-12 01:32:42 +00:00
|
|
|
inline UChar doCharAt(int32_t offset) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
UnicodeString& doReplace(int32_t start,
|
|
|
|
int32_t length,
|
|
|
|
const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength);
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
UnicodeString& doReplace(int32_t start,
|
|
|
|
int32_t length,
|
|
|
|
const UChar *srcChars,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength);
|
|
|
|
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString& doReverse(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t length);
|
|
|
|
|
|
|
|
// calculate hash code
|
2000-04-12 20:04:41 +00:00
|
|
|
int32_t doHashCode(void) const;
|
2001-01-02 19:37:08 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
// get pointer to start of array
|
2007-09-28 04:50:25 +00:00
|
|
|
// these do not check for kOpenGetBuffer, unlike the public getBuffer() function
|
1999-12-28 23:39:02 +00:00
|
|
|
inline UChar* getArrayStart(void);
|
|
|
|
inline const UChar* getArrayStart(void) const;
|
|
|
|
|
2007-09-28 04:50:25 +00:00
|
|
|
// A UnicodeString object (not necessarily its current buffer)
|
|
|
|
// is writable unless it isBogus() or it has an "open" getBuffer(minCapacity).
|
|
|
|
inline UBool isWritable() const;
|
|
|
|
|
|
|
|
// Is the current buffer writable?
|
|
|
|
inline UBool isBufferWritable() const;
|
|
|
|
|
|
|
|
// None of the following does releaseArray().
|
|
|
|
inline void setLength(int32_t len); // sets only fShortLength and fLength
|
|
|
|
inline void setToEmpty(); // sets fFlags=kShortString
|
|
|
|
inline void setArray(UChar *array, int32_t len, int32_t capacity); // does not set fFlags
|
|
|
|
|
2000-03-29 01:13:49 +00:00
|
|
|
// allocate the array; result may be fStackBuffer
|
|
|
|
// sets refCount to 1 if appropriate
|
|
|
|
// sets fArray, fCapacity, and fFlags
|
|
|
|
// returns boolean for success or failure
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool allocate(int32_t capacity);
|
2000-03-29 01:13:49 +00:00
|
|
|
|
|
|
|
// release the array if owned
|
2002-02-28 01:42:40 +00:00
|
|
|
void releaseArray(void);
|
2000-03-29 01:13:49 +00:00
|
|
|
|
2002-11-16 01:05:36 +00:00
|
|
|
// turn a bogus string into an empty one
|
|
|
|
void unBogus();
|
|
|
|
|
2002-10-12 00:59:36 +00:00
|
|
|
// implements assigment operator, copy constructor, and fastCopyFrom()
|
|
|
|
UnicodeString ©From(const UnicodeString &src, UBool fastCopy=FALSE);
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
// Pin start and limit to acceptable values.
|
2002-11-26 23:32:55 +00:00
|
|
|
inline void pinIndex(int32_t& start) const;
|
2002-03-12 01:32:42 +00:00
|
|
|
inline void pinIndices(int32_t& start,
|
2000-04-01 00:21:57 +00:00
|
|
|
int32_t& length) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-26 22:58:39 +00:00
|
|
|
#if !UCONFIG_NO_CONVERSION
|
|
|
|
|
2001-09-18 01:12:14 +00:00
|
|
|
/* Internal extract() using UConverter. */
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t doExtract(int32_t start, int32_t length,
|
2001-09-18 01:12:14 +00:00
|
|
|
char *dest, int32_t destCapacity,
|
|
|
|
UConverter *cnv,
|
|
|
|
UErrorCode &errorCode) const;
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/*
|
|
|
|
* Real constructor for converting from codepage data.
|
|
|
|
* It assumes that it is called with !fRefCounted.
|
|
|
|
*
|
|
|
|
* If <code>codepage==0</code>, then the default converter
|
|
|
|
* is used for the platform encoding.
|
|
|
|
* If <code>codepage</code> is an empty string (<code>""</code>),
|
|
|
|
* then a simple conversion is performed on the codepage-invariant
|
|
|
|
* subset ("invariant characters") of the platform encoding. See utypes.h.
|
|
|
|
*/
|
|
|
|
void doCodepageCreate(const char *codepageData,
|
2000-03-29 01:13:49 +00:00
|
|
|
int32_t dataLength,
|
|
|
|
const char *codepage);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2001-09-18 01:12:14 +00:00
|
|
|
/*
|
|
|
|
* Worker function for creating a UnicodeString from
|
|
|
|
* a codepage string using a UConverter.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
doCodepageCreate(const char *codepageData,
|
|
|
|
int32_t dataLength,
|
|
|
|
UConverter *converter,
|
|
|
|
UErrorCode &status);
|
2004-08-26 22:58:39 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2000-03-29 01:13:49 +00:00
|
|
|
/*
|
|
|
|
* This function is called when write access to the array
|
|
|
|
* is necessary.
|
|
|
|
*
|
|
|
|
* We need to make a copy of the array if
|
|
|
|
* the buffer is read-only, or
|
|
|
|
* the buffer is refCounted (shared), and refCount>1, or
|
|
|
|
* the buffer is too small.
|
|
|
|
*
|
|
|
|
* Return FALSE if memory could not be allocated.
|
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool cloneArrayIfNeeded(int32_t newCapacity = -1,
|
2000-03-29 01:13:49 +00:00
|
|
|
int32_t growCapacity = -1,
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool doCopyArray = TRUE,
|
2001-02-02 20:41:18 +00:00
|
|
|
int32_t **pBufferToDelete = 0,
|
|
|
|
UBool forceClone = FALSE);
|
|
|
|
|
2011-06-03 05:23:57 +00:00
|
|
|
/**
|
|
|
|
* Common function for UnicodeString case mappings.
|
|
|
|
* The stringCaseMapper has the same type UStringCaseMapper
|
|
|
|
* as in ustr_imp.h for ustrcase_map().
|
|
|
|
*/
|
2001-02-14 01:10:10 +00:00
|
|
|
UnicodeString &
|
2011-06-03 05:23:57 +00:00
|
|
|
caseMap(const UCaseMap *csm, UStringCaseMapper *stringCaseMapper);
|
2001-02-14 01:10:10 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
// ref counting
|
2002-03-09 00:36:54 +00:00
|
|
|
void addRef(void);
|
|
|
|
int32_t removeRef(void);
|
|
|
|
int32_t refCount(void) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
// constants
|
2000-03-29 01:13:49 +00:00
|
|
|
enum {
|
2011-02-04 19:54:58 +00:00
|
|
|
// Set the stack buffer size so that sizeof(UnicodeString) is,
|
|
|
|
// naturally (without padding), a multiple of sizeof(pointer).
|
|
|
|
US_STACKBUF_SIZE= sizeof(void *)==4 ? 13 : 15, // Size of stack buffer for short strings
|
2000-03-29 01:13:49 +00:00
|
|
|
kInvalidUChar=0xffff, // invalid UChar index
|
|
|
|
kGrowSize=128, // grow size for this buffer
|
|
|
|
kInvalidHashCode=0, // invalid hash code
|
|
|
|
kEmptyHashCode=1, // hash code for empty string
|
|
|
|
|
|
|
|
// bit flag values for fFlags
|
2002-11-16 01:05:36 +00:00
|
|
|
kIsBogus=1, // this string is bogus, i.e., not valid or NULL
|
2011-02-04 19:54:58 +00:00
|
|
|
kUsingStackBuffer=2,// using fUnion.fStackBuffer instead of fUnion.fFields
|
2001-09-20 01:14:37 +00:00
|
|
|
kRefCounted=4, // there is a refCount field before the characters in fArray
|
|
|
|
kBufferIsReadonly=8,// do not write to this buffer
|
|
|
|
kOpenGetBuffer=16, // getBuffer(minCapacity) was called (is "open"),
|
|
|
|
// and releaseBuffer(newLength) must be called
|
2000-03-29 01:13:49 +00:00
|
|
|
|
|
|
|
// combined values for convenience
|
|
|
|
kShortString=kUsingStackBuffer,
|
|
|
|
kLongString=kRefCounted,
|
|
|
|
kReadonlyAlias=kBufferIsReadonly,
|
2001-09-20 01:14:37 +00:00
|
|
|
kWritableAlias=0
|
2000-03-29 01:13:49 +00:00
|
|
|
};
|
|
|
|
|
2002-03-13 04:46:42 +00:00
|
|
|
friend class StringThreadTest;
|
2011-02-03 22:07:22 +00:00
|
|
|
friend class UnicodeStringAppendable;
|
2007-10-03 20:59:45 +00:00
|
|
|
|
|
|
|
union StackBufferOrFields; // forward declaration necessary before friend declaration
|
2007-10-03 19:18:52 +00:00
|
|
|
friend union StackBufferOrFields; // make US_STACKBUF_SIZE visible inside fUnion
|
2000-03-29 01:13:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The following are all the class fields that are stored
|
|
|
|
* in each UnicodeString object.
|
|
|
|
* Note that UnicodeString has virtual functions,
|
|
|
|
* therefore there is an implicit vtable pointer
|
|
|
|
* as the first real field.
|
2011-02-04 19:54:58 +00:00
|
|
|
* The fields should be aligned such that no padding is necessary.
|
2000-04-12 20:04:41 +00:00
|
|
|
* On 32-bit machines, the size should be 32 bytes,
|
|
|
|
* on 64-bit machines (8-byte pointers), it should be 40 bytes.
|
2011-02-04 19:54:58 +00:00
|
|
|
*
|
|
|
|
* We use a hack to achieve this.
|
|
|
|
*
|
|
|
|
* With at least some compilers, each of the following is forced to
|
|
|
|
* a multiple of sizeof(pointer) [the largest field base unit here is a data pointer],
|
|
|
|
* rounded up with additional padding if the fields do not already fit that requirement:
|
|
|
|
* - sizeof(class UnicodeString)
|
|
|
|
* - offsetof(UnicodeString, fUnion)
|
|
|
|
* - sizeof(fUnion)
|
|
|
|
* - sizeof(fFields)
|
|
|
|
*
|
|
|
|
* In order to avoid padding, we make sizeof(fStackBuffer)=16 (=8 UChars)
|
|
|
|
* which is at least as large as sizeof(fFields) on 32-bit and 64-bit machines.
|
|
|
|
* (Padding at the end of fFields is ok:
|
|
|
|
* As long as there is no padding after fStackBuffer, it is not wasted space.)
|
|
|
|
*
|
|
|
|
* We further assume that the compiler does not reorder the fields,
|
|
|
|
* so that fRestOfStackBuffer (which holds a few more UChars) immediately follows after fUnion,
|
|
|
|
* with at most some padding (but no other field) in between.
|
|
|
|
* (Padding there would be wasted space, but functionally harmless.)
|
|
|
|
*
|
|
|
|
* We use a few more sizeof(pointer)'s chunks of space with
|
|
|
|
* fRestOfStackBuffer, fShortLength and fFlags,
|
|
|
|
* to get up exactly to the intended sizeof(UnicodeString).
|
2000-03-29 01:13:49 +00:00
|
|
|
*/
|
|
|
|
// (implicit) *vtable;
|
2007-10-03 19:18:52 +00:00
|
|
|
union StackBufferOrFields {
|
2007-09-28 04:50:25 +00:00
|
|
|
// fStackBuffer is used iff (fFlags&kUsingStackBuffer)
|
|
|
|
// else fFields is used
|
2011-02-04 19:54:58 +00:00
|
|
|
UChar fStackBuffer[8]; // buffer for short strings, together with fRestOfStackBuffer
|
2007-09-28 04:50:25 +00:00
|
|
|
struct {
|
2011-02-04 19:54:58 +00:00
|
|
|
UChar *fArray; // the Unicode data
|
|
|
|
int32_t fCapacity; // capacity of fArray (in UChars)
|
|
|
|
int32_t fLength; // number of characters in fArray if >127; else undefined
|
2007-09-28 04:50:25 +00:00
|
|
|
} fFields;
|
|
|
|
} fUnion;
|
2011-02-04 19:54:58 +00:00
|
|
|
UChar fRestOfStackBuffer[US_STACKBUF_SIZE-8];
|
|
|
|
int8_t fShortLength; // 0..127: length <0: real length is in fUnion.fFields.fLength
|
|
|
|
uint8_t fFlags; // bit flags: see constants above
|
1999-12-28 23:39:02 +00:00
|
|
|
};
|
|
|
|
|
2003-10-31 21:28:46 +00:00
|
|
|
/**
|
|
|
|
* Create a new UnicodeString with the concatenation of two others.
|
|
|
|
*
|
|
|
|
* @param s1 The first string to be copied to the new one.
|
|
|
|
* @param s2 The second string to be copied to the new one, after s1.
|
|
|
|
* @return UnicodeString(s1).append(s2)
|
2005-06-22 23:38:06 +00:00
|
|
|
* @stable ICU 2.8
|
2003-10-31 21:28:46 +00:00
|
|
|
*/
|
2004-07-16 15:43:19 +00:00
|
|
|
U_COMMON_API UnicodeString U_EXPORT2
|
2003-10-31 21:28:46 +00:00
|
|
|
operator+ (const UnicodeString &s1, const UnicodeString &s2);
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
//========================================
|
|
|
|
// Inline members
|
|
|
|
//========================================
|
|
|
|
|
2003-02-06 22:57:35 +00:00
|
|
|
//========================================
|
|
|
|
// Privates
|
|
|
|
//========================================
|
|
|
|
|
|
|
|
inline void
|
|
|
|
UnicodeString::pinIndex(int32_t& start) const
|
|
|
|
{
|
|
|
|
// pin index
|
|
|
|
if(start < 0) {
|
|
|
|
start = 0;
|
2007-09-28 04:50:25 +00:00
|
|
|
} else if(start > length()) {
|
|
|
|
start = length();
|
2003-02-06 22:57:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
UnicodeString::pinIndices(int32_t& start,
|
|
|
|
int32_t& _length) const
|
|
|
|
{
|
|
|
|
// pin indices
|
2007-09-28 04:50:25 +00:00
|
|
|
int32_t len = length();
|
2003-02-06 22:57:35 +00:00
|
|
|
if(start < 0) {
|
|
|
|
start = 0;
|
2007-09-28 04:50:25 +00:00
|
|
|
} else if(start > len) {
|
|
|
|
start = len;
|
2003-02-06 22:57:35 +00:00
|
|
|
}
|
|
|
|
if(_length < 0) {
|
|
|
|
_length = 0;
|
2007-09-28 04:50:25 +00:00
|
|
|
} else if(_length > (len - start)) {
|
|
|
|
_length = (len - start);
|
2003-02-06 22:57:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UChar*
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::getArrayStart()
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return (fFlags&kUsingStackBuffer) ? fUnion.fStackBuffer : fUnion.fFields.fArray; }
|
2003-02-06 22:57:35 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline const UChar*
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::getArrayStart() const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return (fFlags&kUsingStackBuffer) ? fUnion.fStackBuffer : fUnion.fFields.fArray; }
|
2003-02-06 22:57:35 +00:00
|
|
|
|
|
|
|
//========================================
|
|
|
|
// Read-only implementation methods
|
|
|
|
//========================================
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::length() const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return fShortLength>=0 ? fShortLength : fUnion.fFields.fLength; }
|
2003-02-06 22:57:35 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::getCapacity() const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return (fFlags&kUsingStackBuffer) ? US_STACKBUF_SIZE : fUnion.fFields.fCapacity; }
|
2003-02-06 22:57:35 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::hashCode() const
|
|
|
|
{ return doHashCode(); }
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UBool
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::isBogus() const
|
|
|
|
{ return (UBool)(fFlags & kIsBogus); }
|
|
|
|
|
2007-09-28 04:50:25 +00:00
|
|
|
inline UBool
|
|
|
|
UnicodeString::isWritable() const
|
|
|
|
{ return (UBool)!(fFlags&(kOpenGetBuffer|kIsBogus)); }
|
|
|
|
|
|
|
|
inline UBool
|
|
|
|
UnicodeString::isBufferWritable() const
|
|
|
|
{
|
|
|
|
return (UBool)(
|
|
|
|
!(fFlags&(kOpenGetBuffer|kIsBogus|kBufferIsReadonly)) &&
|
|
|
|
(!(fFlags&kRefCounted) || refCount()==1));
|
|
|
|
}
|
|
|
|
|
2003-02-06 22:57:35 +00:00
|
|
|
inline const UChar *
|
|
|
|
UnicodeString::getBuffer() const {
|
2007-09-28 04:50:25 +00:00
|
|
|
if(fFlags&(kIsBogus|kOpenGetBuffer)) {
|
2003-02-06 22:57:35 +00:00
|
|
|
return 0;
|
2007-09-28 04:50:25 +00:00
|
|
|
} else if(fFlags&kUsingStackBuffer) {
|
|
|
|
return fUnion.fStackBuffer;
|
|
|
|
} else {
|
|
|
|
return fUnion.fFields.fArray;
|
2003-02-06 22:57:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
//========================================
|
|
|
|
// Read-only alias methods
|
|
|
|
//========================================
|
2003-02-06 22:57:35 +00:00
|
|
|
inline int8_t
|
|
|
|
UnicodeString::doCompare(int32_t start,
|
2008-01-20 19:11:49 +00:00
|
|
|
int32_t thisLength,
|
2003-02-06 22:57:35 +00:00
|
|
|
const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
|
|
|
int32_t srcLength) const
|
|
|
|
{
|
2003-04-30 02:41:01 +00:00
|
|
|
if(srcText.isBogus()) {
|
|
|
|
return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise
|
2003-02-06 22:57:35 +00:00
|
|
|
} else {
|
2003-04-30 02:41:01 +00:00
|
|
|
srcText.pinIndices(srcStart, srcLength);
|
2008-01-20 19:11:49 +00:00
|
|
|
return doCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
|
2003-02-06 22:57:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::operator== (const UnicodeString& text) const
|
|
|
|
{
|
|
|
|
if(isBogus()) {
|
|
|
|
return text.isBogus();
|
|
|
|
} else {
|
2007-09-28 04:50:25 +00:00
|
|
|
int32_t len = length(), textLength = text.length();
|
2012-10-08 18:24:41 +00:00
|
|
|
return !text.isBogus() && len == textLength && doEquals(text, len);
|
1999-12-28 23:39:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::operator!= (const UnicodeString& text) const
|
|
|
|
{ return (! operator==(text)); }
|
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::operator> (const UnicodeString& text) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doCompare(0, length(), text, 0, text.length()) == 1; }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::operator< (const UnicodeString& text) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doCompare(0, length(), text, 0, text.length()) == -1; }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::operator>= (const UnicodeString& text) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doCompare(0, length(), text, 0, text.length()) != -1; }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::operator<= (const UnicodeString& text) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doCompare(0, length(), text, 0, text.length()) != 1; }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::compare(const UnicodeString& text) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doCompare(0, length(), text, 0, text.length()); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::compare(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UnicodeString& srcText) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doCompare(start, _length, srcText, 0, srcText.length()); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::compare(const UChar *srcChars,
|
|
|
|
int32_t srcLength) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doCompare(0, length(), srcChars, 0, srcLength); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::compare(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength) const
|
2003-02-06 22:57:35 +00:00
|
|
|
{ return doCompare(start, _length, srcText, srcStart, srcLength); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::compare(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UChar *srcChars) const
|
2003-02-06 22:57:35 +00:00
|
|
|
{ return doCompare(start, _length, srcChars, 0, _length); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::compare(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UChar *srcChars,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength) const
|
2003-02-06 22:57:35 +00:00
|
|
|
{ return doCompare(start, _length, srcChars, srcStart, srcLength); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::compareBetween(int32_t start,
|
|
|
|
int32_t limit,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
|
|
|
int32_t srcLimit) const
|
2004-08-24 17:21:14 +00:00
|
|
|
{ return doCompare(start, limit - start,
|
1999-12-28 23:39:02 +00:00
|
|
|
srcText, srcStart, srcLimit - srcStart); }
|
|
|
|
|
|
|
|
inline int8_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::doCompareCodePointOrder(int32_t start,
|
2008-01-20 19:11:49 +00:00
|
|
|
int32_t thisLength,
|
2003-02-06 22:57:35 +00:00
|
|
|
const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
|
|
|
int32_t srcLength) const
|
1999-12-28 23:39:02 +00:00
|
|
|
{
|
2003-04-30 02:41:01 +00:00
|
|
|
if(srcText.isBogus()) {
|
|
|
|
return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise
|
1999-12-28 23:39:02 +00:00
|
|
|
} else {
|
2003-04-30 02:41:01 +00:00
|
|
|
srcText.pinIndices(srcStart, srcLength);
|
2008-01-20 19:11:49 +00:00
|
|
|
return doCompareCodePointOrder(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
|
1999-12-28 23:39:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
2001-01-24 02:37:58 +00:00
|
|
|
UnicodeString::compareCodePointOrder(const UnicodeString& text) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doCompareCodePointOrder(0, length(), text, 0, text.length()); }
|
2001-01-24 02:37:58 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::compareCodePointOrder(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
2001-01-24 02:37:58 +00:00
|
|
|
const UnicodeString& srcText) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doCompareCodePointOrder(start, _length, srcText, 0, srcText.length()); }
|
2001-01-24 02:37:58 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
2001-01-24 02:37:58 +00:00
|
|
|
UnicodeString::compareCodePointOrder(const UChar *srcChars,
|
|
|
|
int32_t srcLength) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doCompareCodePointOrder(0, length(), srcChars, 0, srcLength); }
|
2001-01-24 02:37:58 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::compareCodePointOrder(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
2001-01-24 02:37:58 +00:00
|
|
|
const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2001-01-24 02:37:58 +00:00
|
|
|
int32_t srcLength) const
|
2003-02-06 22:57:35 +00:00
|
|
|
{ return doCompareCodePointOrder(start, _length, srcText, srcStart, srcLength); }
|
2001-01-24 02:37:58 +00:00
|
|
|
|
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::compareCodePointOrder(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
2001-01-24 02:37:58 +00:00
|
|
|
const UChar *srcChars) const
|
2003-02-06 22:57:35 +00:00
|
|
|
{ return doCompareCodePointOrder(start, _length, srcChars, 0, _length); }
|
2001-01-24 02:37:58 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::compareCodePointOrder(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
2001-01-24 02:37:58 +00:00
|
|
|
const UChar *srcChars,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2001-01-24 02:37:58 +00:00
|
|
|
int32_t srcLength) const
|
2003-02-06 22:57:35 +00:00
|
|
|
{ return doCompareCodePointOrder(start, _length, srcChars, srcStart, srcLength); }
|
2001-01-24 02:37:58 +00:00
|
|
|
|
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::compareCodePointOrderBetween(int32_t start,
|
|
|
|
int32_t limit,
|
2001-01-24 02:37:58 +00:00
|
|
|
const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
|
|
|
int32_t srcLimit) const
|
2004-08-24 17:21:14 +00:00
|
|
|
{ return doCompareCodePointOrder(start, limit - start,
|
2001-01-24 02:37:58 +00:00
|
|
|
srcText, srcStart, srcLimit - srcStart); }
|
|
|
|
|
|
|
|
inline int8_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::doCaseCompare(int32_t start,
|
2008-01-20 19:11:49 +00:00
|
|
|
int32_t thisLength,
|
2003-02-06 22:57:35 +00:00
|
|
|
const UnicodeString &srcText,
|
|
|
|
int32_t srcStart,
|
|
|
|
int32_t srcLength,
|
|
|
|
uint32_t options) const
|
2001-01-24 02:37:58 +00:00
|
|
|
{
|
2003-04-30 02:41:01 +00:00
|
|
|
if(srcText.isBogus()) {
|
|
|
|
return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise
|
2001-01-24 02:37:58 +00:00
|
|
|
} else {
|
2003-04-30 02:41:01 +00:00
|
|
|
srcText.pinIndices(srcStart, srcLength);
|
2008-01-20 19:11:49 +00:00
|
|
|
return doCaseCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength, options);
|
2001-01-24 02:37:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
2001-02-14 01:10:10 +00:00
|
|
|
UnicodeString::caseCompare(const UnicodeString &text, uint32_t options) const {
|
2007-09-28 04:50:25 +00:00
|
|
|
return doCaseCompare(0, length(), text, 0, text.length(), options);
|
2001-02-14 01:10:10 +00:00
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::caseCompare(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
2001-02-14 01:10:10 +00:00
|
|
|
const UnicodeString &srcText,
|
|
|
|
uint32_t options) const {
|
2007-09-28 04:50:25 +00:00
|
|
|
return doCaseCompare(start, _length, srcText, 0, srcText.length(), options);
|
2001-02-14 01:10:10 +00:00
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
2001-02-14 01:10:10 +00:00
|
|
|
UnicodeString::caseCompare(const UChar *srcChars,
|
|
|
|
int32_t srcLength,
|
|
|
|
uint32_t options) const {
|
2007-09-28 04:50:25 +00:00
|
|
|
return doCaseCompare(0, length(), srcChars, 0, srcLength, options);
|
2001-02-14 01:10:10 +00:00
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::caseCompare(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
2001-02-14 01:10:10 +00:00
|
|
|
const UnicodeString &srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2001-02-14 01:10:10 +00:00
|
|
|
int32_t srcLength,
|
|
|
|
uint32_t options) const {
|
2003-02-06 22:57:35 +00:00
|
|
|
return doCaseCompare(start, _length, srcText, srcStart, srcLength, options);
|
2001-02-14 01:10:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::caseCompare(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
2001-02-14 01:10:10 +00:00
|
|
|
const UChar *srcChars,
|
|
|
|
uint32_t options) const {
|
2003-02-06 22:57:35 +00:00
|
|
|
return doCaseCompare(start, _length, srcChars, 0, _length, options);
|
2001-02-14 01:10:10 +00:00
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::caseCompare(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
2001-02-14 01:10:10 +00:00
|
|
|
const UChar *srcChars,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2001-02-14 01:10:10 +00:00
|
|
|
int32_t srcLength,
|
|
|
|
uint32_t options) const {
|
2003-02-06 22:57:35 +00:00
|
|
|
return doCaseCompare(start, _length, srcChars, srcStart, srcLength, options);
|
2001-02-14 01:10:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline int8_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::caseCompareBetween(int32_t start,
|
|
|
|
int32_t limit,
|
2001-02-14 01:10:10 +00:00
|
|
|
const UnicodeString &srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
|
|
|
int32_t srcLimit,
|
2001-02-14 01:10:10 +00:00
|
|
|
uint32_t options) const {
|
|
|
|
return doCaseCompare(start, limit - start, srcText, srcStart, srcLimit - srcStart, options);
|
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::indexOf(const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
|
|
|
int32_t srcLength,
|
|
|
|
int32_t start,
|
|
|
|
int32_t _length) const
|
2001-02-14 01:10:10 +00:00
|
|
|
{
|
|
|
|
if(!srcText.isBogus()) {
|
|
|
|
srcText.pinIndices(srcStart, srcLength);
|
2003-02-06 22:57:35 +00:00
|
|
|
if(srcLength > 0) {
|
|
|
|
return indexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
|
|
|
|
}
|
2001-02-14 01:10:10 +00:00
|
|
|
}
|
2003-02-06 22:57:35 +00:00
|
|
|
return -1;
|
2001-02-14 01:10:10 +00:00
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::indexOf(const UnicodeString& text) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return indexOf(text, 0, text.length(), 0, length()); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::indexOf(const UnicodeString& text,
|
2002-11-26 23:32:55 +00:00
|
|
|
int32_t start) const {
|
|
|
|
pinIndex(start);
|
2007-09-28 04:50:25 +00:00
|
|
|
return indexOf(text, 0, text.length(), start, length() - start);
|
2002-11-26 23:32:55 +00:00
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::indexOf(const UnicodeString& text,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return indexOf(text, 0, text.length(), start, _length); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::indexOf(const UChar *srcChars,
|
|
|
|
int32_t srcLength,
|
2002-11-26 23:32:55 +00:00
|
|
|
int32_t start) const {
|
|
|
|
pinIndex(start);
|
2007-09-28 04:50:25 +00:00
|
|
|
return indexOf(srcChars, 0, srcLength, start, length() - start);
|
2002-11-26 23:32:55 +00:00
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::indexOf(const UChar *srcChars,
|
|
|
|
int32_t srcLength,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length) const
|
|
|
|
{ return indexOf(srcChars, 0, srcLength, start, _length); }
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::indexOf(UChar c,
|
|
|
|
int32_t start,
|
|
|
|
int32_t _length) const
|
|
|
|
{ return doIndexOf(c, start, _length); }
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::indexOf(UChar32 c,
|
|
|
|
int32_t start,
|
|
|
|
int32_t _length) const
|
|
|
|
{ return doIndexOf(c, start, _length); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::indexOf(UChar c) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doIndexOf(c, 0, length()); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::indexOf(UChar32 c) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return indexOf(c, 0, length()); }
|
2000-04-03 23:53:59 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::indexOf(UChar c,
|
2002-11-26 23:32:55 +00:00
|
|
|
int32_t start) const {
|
|
|
|
pinIndex(start);
|
2007-09-28 04:50:25 +00:00
|
|
|
return doIndexOf(c, start, length() - start);
|
2002-11-26 23:32:55 +00:00
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2000-04-03 23:53:59 +00:00
|
|
|
UnicodeString::indexOf(UChar32 c,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start) const {
|
2002-11-26 23:32:55 +00:00
|
|
|
pinIndex(start);
|
2007-09-28 04:50:25 +00:00
|
|
|
return indexOf(c, start, length() - start);
|
2000-04-03 23:53:59 +00:00
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::lastIndexOf(const UChar *srcChars,
|
|
|
|
int32_t srcLength,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length) const
|
|
|
|
{ return lastIndexOf(srcChars, 0, srcLength, start, _length); }
|
2000-04-03 23:53:59 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::lastIndexOf(const UChar *srcChars,
|
|
|
|
int32_t srcLength,
|
2002-11-26 23:32:55 +00:00
|
|
|
int32_t start) const {
|
|
|
|
pinIndex(start);
|
2007-09-28 04:50:25 +00:00
|
|
|
return lastIndexOf(srcChars, 0, srcLength, start, length() - start);
|
2002-11-26 23:32:55 +00:00
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::lastIndexOf(const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length) const
|
1999-12-28 23:39:02 +00:00
|
|
|
{
|
|
|
|
if(!srcText.isBogus()) {
|
|
|
|
srcText.pinIndices(srcStart, srcLength);
|
|
|
|
if(srcLength > 0) {
|
2003-02-06 22:57:35 +00:00
|
|
|
return lastIndexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
|
1999-12-28 23:39:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::lastIndexOf(const UnicodeString& text,
|
|
|
|
int32_t start,
|
|
|
|
int32_t _length) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return lastIndexOf(text, 0, text.length(), start, _length); }
|
2003-02-06 22:57:35 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::lastIndexOf(const UnicodeString& text,
|
2002-11-26 23:32:55 +00:00
|
|
|
int32_t start) const {
|
|
|
|
pinIndex(start);
|
2007-09-28 04:50:25 +00:00
|
|
|
return lastIndexOf(text, 0, text.length(), start, length() - start);
|
2002-11-26 23:32:55 +00:00
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::lastIndexOf(const UnicodeString& text) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return lastIndexOf(text, 0, text.length(), 0, length()); }
|
2003-02-06 22:57:35 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::lastIndexOf(UChar c,
|
|
|
|
int32_t start,
|
|
|
|
int32_t _length) const
|
|
|
|
{ return doLastIndexOf(c, start, _length); }
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2003-02-06 22:57:35 +00:00
|
|
|
UnicodeString::lastIndexOf(UChar32 c,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length) const {
|
|
|
|
return doLastIndexOf(c, start, _length);
|
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::lastIndexOf(UChar c) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doLastIndexOf(c, 0, length()); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2000-04-03 23:53:59 +00:00
|
|
|
UnicodeString::lastIndexOf(UChar32 c) const {
|
2007-09-28 04:50:25 +00:00
|
|
|
return lastIndexOf(c, 0, length());
|
2000-04-03 23:53:59 +00:00
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::lastIndexOf(UChar c,
|
2002-11-26 23:32:55 +00:00
|
|
|
int32_t start) const {
|
|
|
|
pinIndex(start);
|
2007-09-28 04:50:25 +00:00
|
|
|
return doLastIndexOf(c, start, length() - start);
|
2002-11-26 23:32:55 +00:00
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline int32_t
|
2000-04-03 23:53:59 +00:00
|
|
|
UnicodeString::lastIndexOf(UChar32 c,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t start) const {
|
2002-11-26 23:32:55 +00:00
|
|
|
pinIndex(start);
|
2007-09-28 04:50:25 +00:00
|
|
|
return lastIndexOf(c, start, length() - start);
|
2000-04-03 23:53:59 +00:00
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::startsWith(const UnicodeString& text) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return compare(0, text.length(), text, 0, text.length()) == 0; }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::startsWith(const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength) const
|
|
|
|
{ return doCompare(0, srcLength, srcText, srcStart, srcLength) == 0; }
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UBool
|
2011-07-07 18:21:28 +00:00
|
|
|
UnicodeString::startsWith(const UChar *srcChars, int32_t srcLength) const {
|
|
|
|
if(srcLength < 0) {
|
|
|
|
srcLength = u_strlen(srcChars);
|
|
|
|
}
|
|
|
|
return doCompare(0, srcLength, srcChars, 0, srcLength) == 0;
|
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UBool
|
2011-07-07 18:21:28 +00:00
|
|
|
UnicodeString::startsWith(const UChar *srcChars, int32_t srcStart, int32_t srcLength) const {
|
|
|
|
if(srcLength < 0) {
|
|
|
|
srcLength = u_strlen(srcChars);
|
|
|
|
}
|
|
|
|
return doCompare(0, srcLength, srcChars, srcStart, srcLength) == 0;
|
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::endsWith(const UnicodeString& text) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doCompare(length() - text.length(), text.length(),
|
|
|
|
text, 0, text.length()) == 0; }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::endsWith(const UnicodeString& srcText,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2002-11-26 23:32:55 +00:00
|
|
|
int32_t srcLength) const {
|
|
|
|
srcText.pinIndices(srcStart, srcLength);
|
2007-09-28 04:50:25 +00:00
|
|
|
return doCompare(length() - srcLength, srcLength,
|
2002-11-26 23:32:55 +00:00
|
|
|
srcText, srcStart, srcLength) == 0;
|
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::endsWith(const UChar *srcChars,
|
2002-11-26 23:32:55 +00:00
|
|
|
int32_t srcLength) const {
|
|
|
|
if(srcLength < 0) {
|
|
|
|
srcLength = u_strlen(srcChars);
|
|
|
|
}
|
2007-09-28 04:50:25 +00:00
|
|
|
return doCompare(length() - srcLength, srcLength,
|
2002-11-26 23:32:55 +00:00
|
|
|
srcChars, 0, srcLength) == 0;
|
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::endsWith(const UChar *srcChars,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcStart,
|
2002-11-26 23:32:55 +00:00
|
|
|
int32_t srcLength) const {
|
|
|
|
if(srcLength < 0) {
|
|
|
|
srcLength = u_strlen(srcChars + srcStart);
|
|
|
|
}
|
2007-09-28 04:50:25 +00:00
|
|
|
return doCompare(length() - srcLength, srcLength,
|
2002-11-26 23:32:55 +00:00
|
|
|
srcChars, srcStart, srcLength) == 0;
|
|
|
|
}
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
//========================================
|
|
|
|
// replace
|
|
|
|
//========================================
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::replace(int32_t start,
|
|
|
|
int32_t _length,
|
|
|
|
const UnicodeString& srcText)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doReplace(start, _length, srcText, 0, srcText.length()); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::replace(int32_t start,
|
|
|
|
int32_t _length,
|
|
|
|
const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength)
|
2003-02-06 22:57:35 +00:00
|
|
|
{ return doReplace(start, _length, srcText, srcStart, srcLength); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::replace(int32_t start,
|
|
|
|
int32_t _length,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UChar *srcChars,
|
|
|
|
int32_t srcLength)
|
2003-02-06 22:57:35 +00:00
|
|
|
{ return doReplace(start, _length, srcChars, 0, srcLength); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::replace(int32_t start,
|
|
|
|
int32_t _length,
|
|
|
|
const UChar *srcChars,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength)
|
2003-02-06 22:57:35 +00:00
|
|
|
{ return doReplace(start, _length, srcChars, srcStart, srcLength); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::replace(int32_t start,
|
|
|
|
int32_t _length,
|
1999-12-28 23:39:02 +00:00
|
|
|
UChar srcChar)
|
2003-02-06 22:57:35 +00:00
|
|
|
{ return doReplace(start, _length, &srcChar, 0, 1); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::replaceBetween(int32_t start,
|
|
|
|
int32_t limit,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UnicodeString& srcText)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doReplace(start, limit - start, srcText, 0, srcText.length()); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
inline UnicodeString&
|
2004-08-24 17:21:14 +00:00
|
|
|
UnicodeString::replaceBetween(int32_t start,
|
|
|
|
int32_t limit,
|
|
|
|
const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t srcLimit)
|
1999-12-28 23:39:02 +00:00
|
|
|
{ return doReplace(start, limit - start, srcText, srcStart, srcLimit - srcStart); }
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::findAndReplace(const UnicodeString& oldText,
|
|
|
|
const UnicodeString& newText)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return findAndReplace(0, length(), oldText, 0, oldText.length(),
|
|
|
|
newText, 0, newText.length()); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::findAndReplace(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UnicodeString& oldText,
|
|
|
|
const UnicodeString& newText)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return findAndReplace(start, _length, oldText, 0, oldText.length(),
|
|
|
|
newText, 0, newText.length()); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
// ============================
|
|
|
|
// extract
|
|
|
|
// ============================
|
|
|
|
inline void
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::doExtract(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString& target) const
|
2007-09-28 04:50:25 +00:00
|
|
|
{ target.replace(0, target.length(), *this, start, _length); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline void
|
|
|
|
UnicodeString::extract(int32_t start,
|
|
|
|
int32_t _length,
|
|
|
|
UChar *target,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t targetStart) const
|
2003-02-06 22:57:35 +00:00
|
|
|
{ doExtract(start, _length, target, targetStart); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline void
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::extract(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString& target) const
|
2003-02-06 22:57:35 +00:00
|
|
|
{ doExtract(start, _length, target); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-26 22:58:39 +00:00
|
|
|
#if !UCONFIG_NO_CONVERSION
|
|
|
|
|
2000-08-23 02:10:08 +00:00
|
|
|
inline int32_t
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::extract(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length,
|
2000-08-23 02:10:08 +00:00
|
|
|
char *dst,
|
|
|
|
const char *codepage) const
|
2001-09-18 01:12:14 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
// This dstSize value will be checked explicitly
|
2009-11-11 15:47:22 +00:00
|
|
|
return extract(start, _length, dst, dst!=0 ? 0xffffffff : 0, codepage);
|
2001-09-18 01:12:14 +00:00
|
|
|
}
|
2000-08-23 02:10:08 +00:00
|
|
|
|
2004-08-26 22:58:39 +00:00
|
|
|
#endif
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline void
|
|
|
|
UnicodeString::extractBetween(int32_t start,
|
|
|
|
int32_t limit,
|
|
|
|
UChar *dst,
|
2004-05-06 17:41:09 +00:00
|
|
|
int32_t dstStart) const {
|
|
|
|
pinIndex(start);
|
|
|
|
pinIndex(limit);
|
|
|
|
doExtract(start, limit - start, dst, dstStart);
|
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2010-01-06 23:50:03 +00:00
|
|
|
inline UnicodeString
|
|
|
|
UnicodeString::tempSubStringBetween(int32_t start, int32_t limit) const {
|
|
|
|
return tempSubString(start, limit - start);
|
|
|
|
}
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
inline UChar
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::doCharAt(int32_t offset) const
|
1999-12-28 23:39:02 +00:00
|
|
|
{
|
2007-09-28 04:50:25 +00:00
|
|
|
if((uint32_t)offset < (uint32_t)length()) {
|
|
|
|
return getArrayStart()[offset];
|
2000-04-01 00:21:57 +00:00
|
|
|
} else {
|
2000-03-29 01:13:49 +00:00
|
|
|
return kInvalidUChar;
|
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline UChar
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::charAt(int32_t offset) const
|
1999-12-28 23:39:02 +00:00
|
|
|
{ return doCharAt(offset); }
|
|
|
|
|
|
|
|
inline UChar
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::operator[] (int32_t offset) const
|
1999-12-28 23:39:02 +00:00
|
|
|
{ return doCharAt(offset); }
|
|
|
|
|
2002-11-13 22:36:43 +00:00
|
|
|
inline UBool
|
|
|
|
UnicodeString::isEmpty() const {
|
2007-09-28 04:50:25 +00:00
|
|
|
return fShortLength == 0;
|
2002-11-13 22:36:43 +00:00
|
|
|
}
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
//========================================
|
2002-06-08 19:35:15 +00:00
|
|
|
// Write implementation methods
|
1999-12-28 23:39:02 +00:00
|
|
|
//========================================
|
2007-09-28 04:50:25 +00:00
|
|
|
inline void
|
|
|
|
UnicodeString::setLength(int32_t len) {
|
|
|
|
if(len <= 127) {
|
|
|
|
fShortLength = (int8_t)len;
|
|
|
|
} else {
|
|
|
|
fShortLength = (int8_t)-1;
|
|
|
|
fUnion.fFields.fLength = len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
UnicodeString::setToEmpty() {
|
|
|
|
fShortLength = 0;
|
|
|
|
fFlags = kShortString;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
UnicodeString::setArray(UChar *array, int32_t len, int32_t capacity) {
|
|
|
|
setLength(len);
|
|
|
|
fUnion.fFields.fArray = array;
|
|
|
|
fUnion.fFields.fCapacity = capacity;
|
|
|
|
}
|
|
|
|
|
2002-06-08 19:35:15 +00:00
|
|
|
inline const UChar *
|
|
|
|
UnicodeString::getTerminatedBuffer() {
|
2007-09-28 04:50:25 +00:00
|
|
|
if(!isWritable()) {
|
2002-06-08 19:35:15 +00:00
|
|
|
return 0;
|
|
|
|
} else {
|
2007-09-28 04:50:25 +00:00
|
|
|
UChar *array = getArrayStart();
|
|
|
|
int32_t len = length();
|
2010-01-06 23:50:03 +00:00
|
|
|
if(len < getCapacity() && ((fFlags&kRefCounted) == 0 || refCount() == 1)) {
|
|
|
|
/*
|
|
|
|
* kRefCounted: Do not write the NUL if the buffer is shared.
|
|
|
|
* That is mostly safe, except when the length of one copy was modified
|
|
|
|
* without copy-on-write, e.g., via truncate(newLength) or remove(void).
|
|
|
|
* Then the NUL would be written into the middle of another copy's string.
|
|
|
|
*/
|
2009-05-14 06:05:27 +00:00
|
|
|
if(!(fFlags&kBufferIsReadonly)) {
|
|
|
|
/*
|
|
|
|
* We must not write to a readonly buffer, but it is known to be
|
|
|
|
* NUL-terminated if len<capacity.
|
|
|
|
* A shared, allocated buffer (refCount()>1) must not have its contents
|
|
|
|
* modified, but the NUL at [len] is beyond the string contents,
|
|
|
|
* and multiple string objects and threads writing the same NUL into the
|
|
|
|
* same location is harmless.
|
|
|
|
* In all other cases, the buffer is fully writable and it is anyway safe
|
|
|
|
* to write the NUL.
|
|
|
|
*
|
|
|
|
* Note: An earlier version of this code tested whether there is a NUL
|
|
|
|
* at [len] already, but, while safe, it generated lots of warnings from
|
|
|
|
* tools like valgrind and Purify.
|
|
|
|
*/
|
2009-05-13 21:05:51 +00:00
|
|
|
array[len] = 0;
|
|
|
|
}
|
2007-09-28 04:50:25 +00:00
|
|
|
return array;
|
2009-05-13 21:05:51 +00:00
|
|
|
} else if(cloneArrayIfNeeded(len+1)) {
|
2007-09-28 04:50:25 +00:00
|
|
|
array = getArrayStart();
|
|
|
|
array[len] = 0;
|
|
|
|
return array;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
2002-06-08 19:35:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::operator= (UChar ch)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doReplace(0, length(), &ch, 0, 1); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::operator= (UChar32 ch)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return replace(0, length(), ch); }
|
2000-05-24 20:03:21 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::setTo(const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength)
|
2002-11-16 01:05:36 +00:00
|
|
|
{
|
|
|
|
unBogus();
|
2007-09-28 04:50:25 +00:00
|
|
|
return doReplace(0, length(), srcText, srcStart, srcLength);
|
2002-11-16 01:05:36 +00:00
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::setTo(const UnicodeString& srcText,
|
2002-04-26 18:02:49 +00:00
|
|
|
int32_t srcStart)
|
2002-11-16 01:05:36 +00:00
|
|
|
{
|
|
|
|
unBogus();
|
2002-11-26 23:32:55 +00:00
|
|
|
srcText.pinIndex(srcStart);
|
2007-09-28 04:50:25 +00:00
|
|
|
return doReplace(0, length(), srcText, srcStart, srcText.length() - srcStart);
|
2002-11-16 01:05:36 +00:00
|
|
|
}
|
2002-04-26 18:02:49 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::setTo(const UnicodeString& srcText)
|
2002-11-16 01:05:36 +00:00
|
|
|
{
|
2011-04-12 15:10:45 +00:00
|
|
|
return copyFrom(srcText);
|
2002-11-16 01:05:36 +00:00
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::setTo(const UChar *srcChars,
|
|
|
|
int32_t srcLength)
|
2002-11-16 01:05:36 +00:00
|
|
|
{
|
|
|
|
unBogus();
|
2007-09-28 04:50:25 +00:00
|
|
|
return doReplace(0, length(), srcChars, 0, srcLength);
|
2002-11-16 01:05:36 +00:00
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::setTo(UChar srcChar)
|
2002-11-16 01:05:36 +00:00
|
|
|
{
|
|
|
|
unBogus();
|
2007-09-28 04:50:25 +00:00
|
|
|
return doReplace(0, length(), &srcChar, 0, 1);
|
2002-11-16 01:05:36 +00:00
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
2000-05-24 20:03:21 +00:00
|
|
|
UnicodeString::setTo(UChar32 srcChar)
|
2002-11-16 01:05:36 +00:00
|
|
|
{
|
|
|
|
unBogus();
|
2007-09-28 04:50:25 +00:00
|
|
|
return replace(0, length(), srcChar);
|
2002-11-16 01:05:36 +00:00
|
|
|
}
|
2000-05-24 20:03:21 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::append(const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doReplace(length(), 0, srcText, srcStart, srcLength); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::append(const UnicodeString& srcText)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doReplace(length(), 0, srcText, 0, srcText.length()); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::append(const UChar *srcChars,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doReplace(length(), 0, srcChars, srcStart, srcLength); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::append(const UChar *srcChars,
|
|
|
|
int32_t srcLength)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doReplace(length(), 0, srcChars, 0, srcLength); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::append(UChar srcChar)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doReplace(length(), 0, &srcChar, 0, 1); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
2006-02-21 18:32:00 +00:00
|
|
|
UnicodeString::operator+= (UChar ch)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doReplace(length(), 0, &ch, 0, 1); }
|
2006-02-21 18:32:00 +00:00
|
|
|
|
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::operator+= (UChar32 ch) {
|
|
|
|
return append(ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::operator+= (const UnicodeString& srcText)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doReplace(length(), 0, srcText, 0, srcText.length()); }
|
2006-02-21 18:32:00 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::insert(int32_t start,
|
|
|
|
const UnicodeString& srcText,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength)
|
|
|
|
{ return doReplace(start, 0, srcText, srcStart, srcLength); }
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::insert(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UnicodeString& srcText)
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doReplace(start, 0, srcText, 0, srcText.length()); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::insert(int32_t start,
|
|
|
|
const UChar *srcChars,
|
|
|
|
int32_t srcStart,
|
1999-12-28 23:39:02 +00:00
|
|
|
int32_t srcLength)
|
|
|
|
{ return doReplace(start, 0, srcChars, srcStart, srcLength); }
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::insert(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
const UChar *srcChars,
|
|
|
|
int32_t srcLength)
|
|
|
|
{ return doReplace(start, 0, srcChars, 0, srcLength); }
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::insert(int32_t start,
|
1999-12-28 23:39:02 +00:00
|
|
|
UChar srcChar)
|
|
|
|
{ return doReplace(start, 0, &srcChar, 0, 1); }
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::insert(int32_t start,
|
2000-05-24 20:03:21 +00:00
|
|
|
UChar32 srcChar)
|
|
|
|
{ return replace(start, 0, srcChar); }
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::remove()
|
2002-11-19 02:12:39 +00:00
|
|
|
{
|
|
|
|
// remove() of a bogus string makes the string empty and non-bogus
|
2010-01-06 23:50:03 +00:00
|
|
|
// we also un-alias a read-only alias to deal with NUL-termination
|
|
|
|
// issues with getTerminatedBuffer()
|
|
|
|
if(fFlags & (kIsBogus|kBufferIsReadonly)) {
|
|
|
|
setToEmpty();
|
2002-11-19 02:12:39 +00:00
|
|
|
} else {
|
2010-01-06 23:50:03 +00:00
|
|
|
fShortLength = 0;
|
2002-11-19 02:12:39 +00:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
|
|
|
UnicodeString::remove(int32_t start,
|
2003-05-16 20:33:01 +00:00
|
|
|
int32_t _length)
|
|
|
|
{
|
2006-08-07 18:02:31 +00:00
|
|
|
if(start <= 0 && _length == INT32_MAX) {
|
|
|
|
// remove(guaranteed everything) of a bogus string makes the string empty and non-bogus
|
2006-08-07 20:29:51 +00:00
|
|
|
return remove();
|
2006-08-07 18:02:31 +00:00
|
|
|
}
|
2006-08-07 20:29:51 +00:00
|
|
|
return doReplace(start, _length, NULL, 0, 0);
|
2003-05-16 20:33:01 +00:00
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::removeBetween(int32_t start,
|
|
|
|
int32_t limit)
|
2000-10-19 21:06:02 +00:00
|
|
|
{ return doReplace(start, limit - start, NULL, 0, 0); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2010-01-06 23:50:03 +00:00
|
|
|
inline UnicodeString &
|
|
|
|
UnicodeString::retainBetween(int32_t start, int32_t limit) {
|
|
|
|
truncate(limit);
|
|
|
|
return doReplace(0, start, NULL, 0, 0);
|
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UBool
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::truncate(int32_t targetLength)
|
|
|
|
{
|
2002-11-19 02:12:39 +00:00
|
|
|
if(isBogus() && targetLength == 0) {
|
|
|
|
// truncate(0) of a bogus string makes the string empty and non-bogus
|
|
|
|
unBogus();
|
|
|
|
return FALSE;
|
2007-09-28 04:50:25 +00:00
|
|
|
} else if((uint32_t)targetLength < (uint32_t)length()) {
|
|
|
|
setLength(targetLength);
|
2010-01-06 23:50:03 +00:00
|
|
|
if(fFlags&kBufferIsReadonly) {
|
|
|
|
fUnion.fFields.fCapacity = targetLength; // not NUL-terminated any more
|
|
|
|
}
|
1999-12-28 23:39:02 +00:00
|
|
|
return TRUE;
|
2000-04-01 00:21:57 +00:00
|
|
|
} else {
|
|
|
|
return FALSE;
|
1999-12-28 23:39:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString::reverse()
|
2007-09-28 04:50:25 +00:00
|
|
|
{ return doReverse(0, length()); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-08-24 17:21:14 +00:00
|
|
|
inline UnicodeString&
|
2002-03-12 01:32:42 +00:00
|
|
|
UnicodeString::reverse(int32_t start,
|
2003-02-06 22:57:35 +00:00
|
|
|
int32_t _length)
|
|
|
|
{ return doReverse(start, _length); }
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
#endif
|