/*
**********************************************************************
-* Copyright (C) 1998-2003, International Business Machines
+* Copyright (C) 1998-2004, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*
#ifndef UNISTR_H
#define UNISTR_H
-#include "unicode/utypes.h"
-#include "unicode/uobject.h"
#include "unicode/rep.h"
struct UConverter; // unicode/ucnv.h
/**
* Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc:
* Compare strings in code point order instead of code unit order.
- * @draft ICU 2.2
+ * @stable ICU 2.2
*/
#define U_COMPARE_CODE_POINT_ORDER 0x8000
#endif
#ifndef USTRING_H
/* see ustring.h */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
u_strlen(const UChar *s);
#endif
U_NAMESPACE_BEGIN
class Locale; // unicode/locid.h
-class UCharReference;
class StringCharacterIterator;
class BreakIterator; // unicode/brkiter.h
/* The <iostream> include has been moved to unicode/ustream.h */
+/**
+ * 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).
+ *
+ * @draft ICU 3.2
+ */
+#define US_INV UnicodeString::kInvariant
+
/**
* Unicode String literals in C++.
* Dependent on the platform properties, different UnicodeString
#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY
# define UNICODE_STRING(cs, _length) UnicodeString(TRUE, (const UChar *)cs, _length)
#else
-# define UNICODE_STRING(cs, _length) UnicodeString(cs, _length, "")
+# define UNICODE_STRING(cs, _length) UnicodeString(cs, _length, US_INV)
#endif
/**
#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY
# define UNICODE_STRING_SIMPLE(cs) UnicodeString(TRUE, (const UChar *)cs, -1)
#else
-# define UNICODE_STRING_SIMPLE(cs) UnicodeString(cs, "")
+# define UNICODE_STRING_SIMPLE(cs) UnicodeString(cs, -1, US_INV)
#endif
/**
*
* <p>In ICU, a Unicode string consists of 16-bit Unicode <em>code units</em>.
* A Unicode character may be stored with either
- * one code unit — which is the most common case — or with a matched pair of
+ * one code unit — which is the most common case — or with a matched pair of
* special code units ("surrogates").
* The data type for code units is UChar.<br>
* For single-character handling, a Unicode character code <em>point</em> is a value
{
public:
+ /**
+ * 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
+ * @draft ICU 3.2
+ */
+ enum EInvariant {
+ /**
+ * @see EInvariant
+ * @draft ICU 3.2
+ */
+ kInvariant
+ };
+
//========================================
// Read-only operations
//========================================
/**
* Greater than operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if the characters in <TT>text</TT> are bitwise
- * greater than the characters in this, FALSE otherwise
+ * @return TRUE if the characters in this are bitwise
+ * greater than the characters in <code>text</code>, FALSE otherwise
* @stable ICU 2.0
*/
inline UBool operator> (const UnicodeString& text) const;
/**
* Less than operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if the characters in <TT>text</TT> are bitwise
- * less than the characters in this, FALSE otherwise
+ * @return TRUE if the characters in this are bitwise
+ * less than the characters in <code>text</code>, FALSE otherwise
* @stable ICU 2.0
*/
inline UBool operator< (const UnicodeString& text) const;
/**
* Greater than or equal operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if the characters in <TT>text</TT> are bitwise
- * greater than or equal to the characters in this, FALSE otherwise
+ * @return TRUE if the characters in this are bitwise
+ * greater than or equal to the characters in <code>text</code>, FALSE otherwise
* @stable ICU 2.0
*/
inline UBool operator>= (const UnicodeString& text) const;
/**
* Less than or equal operator. Performs only bitwise comparison.
* @param text The UnicodeString to compare to this one.
- * @return TRUE if the characters in <TT>text</TT> are bitwise
- * less than or equal to the characters in this, FALSE otherwise
+ * @return TRUE if the characters in this are bitwise
+ * less than or equal to the characters in <code>text</code>, FALSE otherwise
* @stable ICU 2.0
*/
inline UBool operator<= (const UnicodeString& text) const;
/**
* Compare the characters bitwise in this UnicodeString to
- * the characters in <TT>text</TT>.
+ * the characters in <code>text</code>.
* @param text The UnicodeString to compare to this one.
- * @return The result of bitwise character comparison: 0 if <TT>text</TT>
- * contains the same characters as this, -1 if the characters in
- * <TT>text</TT> are bitwise less than the characters in this, +1 if the
- * characters in <TT>text</TT> are bitwise greater than the characters
- * in this.
+ * @return The result of bitwise character comparison: 0 if this
+ * contains the same characters as <code>text</code>, -1 if the characters in
+ * this are bitwise less than the characters in <code>text</code>, +1 if the
+ * characters in this are bitwise greater than the characters
+ * in <code>text</code>.
* @stable ICU 2.0
*/
inline int8_t compare(const UnicodeString& text) const;
/**
- * Compare the characters bitwise in the range
- * [<TT>start</TT>, <TT>start + length</TT>) with the characters
- * in <TT>srcText</TT>
+ * Compare the characters bitwise in the range
+ * [<TT>start</TT>, <TT>start + length</TT>) with the characters
+ * in <TT>text</TT>
* @param start the offset at which the compare operation begins
* @param length the number of characters of text to compare.
- * @param srcText the text to be compared
- * @return The result of bitwise character comparison: 0 if <TT>text</TT>
- * contains the same characters as this, -1 if the characters in
- * <TT>text</TT> are bitwise less than the characters in this, +1 if the
- * characters in <TT>text</TT> are bitwise greater than the characters
- * in this.
+ * @param text the other text to be compared against this string.
+ * @return The result of bitwise character comparison: 0 if this
+ * contains the same characters as <code>text</code>, -1 if the characters in
+ * this are bitwise less than the characters in <code>text</code>, +1 if the
+ * characters in this are bitwise greater than the characters
+ * in <code>text</code>.
* @stable ICU 2.0
*/
inline int8_t compare(int32_t start,
int32_t length,
- const UnicodeString& srcText) const;
+ const UnicodeString& text) const;
/**
- * 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>).
+ * 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>).
* @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
- * @return The result of bitwise character comparison: 0 if <TT>text</TT>
- * contains the same characters as this, -1 if the characters in
- * <TT>text</TT> are bitwise less than the characters in this, +1 if the
- * characters in <TT>text</TT> are bitwise greater than the characters
- * in this.
+ * @return The result of bitwise character comparison: 0 if this
+ * contains the same characters as <code>srcText</code>, -1 if the characters in
+ * this are bitwise less than the characters in <code>srcText</code>, +1 if the
+ * characters in this are bitwise greater than the characters
+ * in <code>srcText</code>.
* @stable ICU 2.0
*/
inline int8_t compare(int32_t start,
int32_t srcLength) const;
/**
- * Compare the characters bitwise in this UnicodeString with the first
+ * Compare the characters bitwise in this UnicodeString with the first
* <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
- * @return The result of bitwise character comparison: 0 if <TT>text</TT>
- * contains the same characters as this, -1 if the characters in
- * <TT>text</TT> are bitwise less than the characters in this, +1 if the
- * characters in <TT>text</TT> are bitwise greater than the characters
- * in this.
+ * @return The result of bitwise character comparison: 0 if this
+ * contains the same characters as <code>srcChars</code>, -1 if the characters in
+ * this are bitwise less than the characters in <code>srcChars</code>, +1 if the
+ * characters in this are bitwise greater than the characters
+ * in <code>srcChars</code>.
* @stable ICU 2.0
*/
inline int8_t compare(const UChar *srcChars,
int32_t srcLength) const;
/**
- * Compare the characters bitwise in the range
- * [<TT>start</TT>, <TT>start + length</TT>) with the first
+ * Compare the characters bitwise in the range
+ * [<TT>start</TT>, <TT>start + length</TT>) with the first
* <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
- * @return The result of bitwise character comparison: 0 if <TT>text</TT>
- * contains the same characters as this, -1 if the characters in
- * <TT>text</TT> are bitwise less than the characters in this, +1 if the
- * characters in <TT>text</TT> are bitwise greater than the characters
- * in this.
+ * @return The result of bitwise character comparison: 0 if this
+ * contains the same characters as <code>srcChars</code>, -1 if the characters in
+ * this are bitwise less than the characters in <code>srcChars</code>, +1 if the
+ * characters in this are bitwise greater than the characters
+ * in <code>srcChars</code>.
* @stable ICU 2.0
*/
inline int8_t compare(int32_t start,
const UChar *srcChars) const;
/**
- * 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>).
+ * 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>).
* @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
- * @return The result of bitwise character comparison: 0 if <TT>text</TT>
- * contains the same characters as this, -1 if the characters in
- * <TT>text</TT> are bitwise less than the characters in this, +1 if the
- * characters in <TT>text</TT> are bitwise greater than the characters
- * in this.
+ * @return The result of bitwise character comparison: 0 if this
+ * contains the same characters as <code>srcChars</code>, -1 if the characters in
+ * this are bitwise less than the characters in <code>srcChars</code>, +1 if the
+ * characters in this are bitwise greater than the characters
+ * in <code>srcChars</code>.
* @stable ICU 2.0
*/
inline int8_t compare(int32_t start,
int32_t srcLength) const;
/**
- * 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>).
+ * 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>).
* @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
- * @return The result of bitwise character comparison: 0 if <TT>text</TT>
- * contains the same characters as this, -1 if the characters in
- * <TT>text</TT> are bitwise less than the characters in this, +1 if the
- * characters in <TT>text</TT> are bitwise greater than the characters
- * in this.
+ * @return The result of bitwise character comparison: 0 if this
+ * contains the same characters as <code>srcText</code>, -1 if the characters in
+ * this are bitwise less than the characters in <code>srcText</code>, +1 if the
+ * characters in this are bitwise greater than the characters
+ * in <code>srcText</code>.
* @stable ICU 2.0
*/
inline int8_t compareBetween(int32_t start,
/**
* Determine if this starts with the characters in <TT>text</TT>
* @param text The text to match.
- * @return TRUE if this starts with the characters in <TT>text</TT>,
+ * @return TRUE if this starts with the characters in <TT>text</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
inline UBool startsWith(const UnicodeString& text) const;
/**
- * Determine if this starts with the characters in <TT>srcText</TT>
- * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
+ * Determine if this starts with the characters in <TT>srcText</TT>
+ * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
* @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
- * @return TRUE if this starts with the characters in <TT>text</TT>,
+ * @return TRUE if this starts with the characters in <TT>text</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
* 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>
- * @return TRUE if this starts with the characters in <TT>srcChars</TT>,
+ * @return TRUE if this starts with the characters in <TT>srcChars</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
int32_t srcLength) const;
/**
- * Determine if this ends with the characters in <TT>srcChars</TT>
- * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
+ * Determine if this ends with the characters in <TT>srcChars</TT>
+ * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
* @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
/**
* Determine if this ends with the characters in <TT>text</TT>
* @param text The text to match.
- * @return TRUE if this ends with the characters in <TT>text</TT>,
+ * @return TRUE if this ends with the characters in <TT>text</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
inline UBool endsWith(const UnicodeString& text) const;
/**
- * Determine if this ends with the characters in <TT>srcText</TT>
- * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
+ * Determine if this ends with the characters in <TT>srcText</TT>
+ * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
* @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
- * @return TRUE if this ends with the characters in <TT>text</TT>,
+ * @return TRUE if this ends with the characters in <TT>text</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
* 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>
- * @return TRUE if this ends with the characters in <TT>srcChars</TT>,
+ * @return TRUE if this ends with the characters in <TT>srcChars</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
int32_t srcLength) const;
/**
- * Determine if this ends with the characters in <TT>srcChars</TT>
- * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
+ * Determine if this ends with the characters in <TT>srcChars</TT>
+ * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
* @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
- * @return TRUE if this ends with the characters in <TT>srcChars</TT>,
+ * @return TRUE if this ends with the characters in <TT>srcChars</TT>,
* FALSE otherwise
* @stable ICU 2.0
*/
* Locate in this the first occurrence of the characters in <TT>text</TT>,
* using bitwise comparison.
* @param text The text to search for.
- * @return The offset into this of the start of <TT>text</TT>,
+ * @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
* 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.
- * @return The offset into this of the start of <TT>text</TT>,
+ * @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
/**
* Locate in this the first occurrence in the range
- * [<TT>start</TT>, <TT>start + length</TT>) of the characters
+ * [<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
- * @return The offset into this of the start of <TT>text</TT>,
+ * @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
/**
* Locate in this the first 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.
+ * in <TT>srcText</TT> in the range
+ * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
+ * using bitwise comparison.
* @param srcText The text to search for.
* @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
- * @return The offset into this of the start of <TT>text</TT>,
+ * @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
/**
* Locate in this the first occurrence of the characters in
- * <TT>srcChars</TT>
- * starting at offset <TT>start</TT>, using bitwise comparison.
+ * <TT>srcChars</TT>
+ * starting at offset <TT>start</TT>, using bitwise comparison.
* @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
- * @return The offset into this of the start of <TT>text</TT>,
+ * @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
/**
* Locate in this the first occurrence in the range
- * [<TT>start</TT>, <TT>start + length</TT>) of the characters
+ * [<TT>start</TT>, <TT>start + length</TT>) of the characters
* in <TT>srcChars</TT>, using bitwise comparison.
* @param srcChars The text to search for.
* @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
- * @return The offset into this of the start of <TT>srcChars</TT>,
+ * @return The offset into this of the start of <TT>srcChars</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
int32_t srcLength,
int32_t start,
int32_t length) const;
-
+
/**
- * 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.
+ * 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.
* @param srcChars The text to search for.
- * @param srcStart the offset into <TT>srcChars</TT> at which
+ * @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
- * @return The offset into this of the start of <TT>text</TT>,
+ * @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
inline int32_t indexOf(UChar c) const;
/**
- * Locate in this the first occurrence of the code point <TT>c</TT>,
+ * Locate in this the first occurrence of the code point <TT>c</TT>,
* using bitwise comparison.
*
* @param c The code point to search for.
/**
* Locate in this the first occurrence of the BMP code point <code>c</code>
- * in the range [<TT>start</TT>, <TT>start + length</TT>),
- * using bitwise comparison.
+ * in the range [<TT>start</TT>, <TT>start + length</TT>),
+ * using bitwise comparison.
* @param c The code unit to search for.
* @param start the offset into this at which to start matching
* @param length the number of characters in this to search
int32_t length) const;
/**
- * 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.
+ * 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.
*
* @param c The code point to search for.
* @param start the offset into this at which to start matching
int32_t length) const;
/**
- * Locate in this the last occurrence of the characters in <TT>text</TT>,
+ * Locate in this the last occurrence of the characters in <TT>text</TT>,
* using bitwise comparison.
* @param text The text to search for.
- * @return The offset into this of the start of <TT>text</TT>,
+ * @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
* 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.
- * @return The offset into this of the start of <TT>text</TT>,
+ * @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
int32_t start) const;
/**
- * Locate in this the last occurrence in the range
+ * Locate in this the last occurrence in the range
* [<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
- * @return The offset into this of the start of <TT>text</TT>,
+ * @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
int32_t length) const;
/**
- * 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.
+ * 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.
* @param srcText The text to search for.
- * @param srcStart the offset into <TT>srcText</TT> at which
+ * @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
- * @return The offset into this of the start of <TT>text</TT>,
+ * @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
int32_t length) const;
/**
- * Locate in this the last occurrence of the characters in <TT>srcChars</TT>
- * starting at offset <TT>start</TT>, using bitwise comparison.
+ * Locate in this the last occurrence of the characters in <TT>srcChars</TT>
+ * starting at offset <TT>start</TT>, using bitwise comparison.
* @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
- * @return The offset into this of the start of <TT>text</TT>,
+ * @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
int32_t start) const;
/**
- * Locate in this the last occurrence in the range
- * [<TT>start</TT>, <TT>start + length</TT>) of the characters
+ * Locate in this the last occurrence in the range
+ * [<TT>start</TT>, <TT>start + length</TT>) of the characters
* in <TT>srcChars</TT>, using bitwise comparison.
* @param srcChars The text to search for.
* @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
- * @return The offset into this of the start of <TT>srcChars</TT>,
+ * @return The offset into this of the start of <TT>srcChars</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
int32_t srcLength,
int32_t start,
int32_t length) const;
-
+
/**
- * 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.
+ * 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.
* @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
- * @return The offset into this of the start of <TT>text</TT>,
+ * @return The offset into this of the start of <TT>text</TT>,
* or -1 if not found.
* @stable ICU 2.0
*/
inline int32_t lastIndexOf(UChar c) const;
/**
- * Locate in this the last occurrence of the code point <TT>c</TT>,
+ * Locate in this the last occurrence of the code point <TT>c</TT>,
* using bitwise comparison.
*
* @param c The code point to search for.
/**
* Locate in this the last occurrence of the BMP code point <code>c</code>
- * in the range [<TT>start</TT>, <TT>start + length</TT>),
- * using bitwise comparison.
+ * in the range [<TT>start</TT>, <TT>start + length</TT>),
+ * using bitwise comparison.
* @param c The code unit to search for.
* @param start the offset into this at which to start matching
* @param length the number of characters in this to search
int32_t length) const;
/**
- * 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.
+ * 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.
*
* @param c The code point to search for.
* @param start the offset into this at which to start matching
/* Substring extraction */
/**
- * Copy the characters in the range
+ * Copy the characters in the range
* [<tt>start</tt>, <tt>start + length</tt>) into the array <tt>dst</tt>,
* beginning at <tt>dstStart</tt>.
* If the string aliases to <code>dst</code> itself as an external buffer,
* will be extracted
* @stable ICU 2.0
*/
- inline void extract(int32_t start,
- int32_t length,
- UChar *dst,
+ inline void extract(int32_t start,
+ int32_t length,
+ UChar *dst,
int32_t dstStart = 0) const;
/**
UErrorCode &errorCode) const;
/**
- * Copy the characters in the range
+ * Copy the characters in the range
* [<tt>start</tt>, <tt>start + length</tt>) into the UnicodeString
* <tt>target</tt>.
* @param start offset of first character which will be copied
UnicodeString& target) const;
/**
- * Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>)
+ * Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>)
* 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
- * @param dst array in which to copy characters. The length of <tt>dst</tt>
+ * @param dst array in which to copy characters. The length of <tt>dst</tt>
* must be at least (<tt>dstStart + (limit - start)</tt>).
* @param dstStart the offset in <TT>dst</TT> where the first character
* will be extracted
* @stable ICU 2.0
*/
- inline void extractBetween(int32_t start,
- int32_t limit,
- UChar *dst,
+ inline void extractBetween(int32_t start,
+ int32_t limit,
+ UChar *dst,
int32_t dstStart = 0) const;
/**
- * Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>)
+ * Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>)
* into the UnicodeString <tt>target</tt>. Replaceable API.
* @param start offset of first character which will be copied
* @param limit offset immediately following the last character to be copied
/**
* 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
+ * @param targetCapacity the length of the target buffer
+ * @param inv Signature-distinguishing paramater, use US_INV.
+ * @return the output string length, not including the terminating NUL
+ * @draft ICU 3.2
+ */
+ int32_t extract(int32_t start,
+ int32_t startLength,
+ char *target,
+ int32_t targetCapacity,
+ enum EInvariant inv) const;
+
+#if !UCONFIG_NO_CONVERSION
+
+ /**
+ * Copy the characters in the range
* [<tt>start</TT>, <tt>start + length</TT>) into an array of characters
* in a specified codepage.
* The output string is NUL-terminated.
*
+ * 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.
+ *
* @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 codepage the desired codepage for the characters. 0 has
+ * @param codepage the desired codepage for the characters. 0 has
* 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
const char *codepage = 0) const;
/**
- * Copy the characters in the range
+ * Copy the characters in the range
* [<tt>start</TT>, <tt>start + length</TT>) into an array of characters
* in a specified codepage.
* This function does not write any more than <code>targetLength</code>
* if necessary.
* The output string is NUL-terminated if possible.
*
+ * 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.
+ *
* @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
- * @param codepage the desired codepage for the characters. 0 has
+ * @param codepage the desired codepage for the characters. 0 has
* 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
UConverter *cnv,
UErrorCode &errorCode) const;
+#endif
+
/* Length operations */
/**
- * Return the length of the UnicodeString object.
- * The length is the number of characters in the text.
+ * Return the length of the UnicodeString object.
+ * The length is the number of UChar code units are in the UnicodeString.
+ * If you want the number of code points, please use countChar32().
* @return the length of the UnicodeString object
+ * @see countChar32
* @stable ICU 2.0
*/
inline int32_t length(void) const;
* @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
+ * @see length
* @stable ICU 2.0
*/
int32_t
* than 'number'. Same as (u_countChar32(s, length)>number).
* @see countChar32
* @see u_strHasMoreChar32Than
- * @draft ICU 2.4
+ * @stable ICU 2.4
*/
UBool
hasMoreChar32Than(int32_t start, int32_t length, int32_t number) const;
*
* @param src The text containing the characters to replace.
* @return a reference to this
- * @draft ICU 2.4
+ * @stable ICU 2.4
*/
UnicodeString &fastCopyFrom(const UnicodeString &src);
/**
* Set the text in the UnicodeString object to the characters
- * in <TT>srcText</TT> in the range
+ * in <TT>srcText</TT> in the range
* [<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
- * @draft ICU2.2
+ * @stable ICU 2.2
*/
- inline UnicodeString& setTo(const UnicodeString& srcText,
+ inline UnicodeString& setTo(const UnicodeString& srcText,
int32_t srcStart);
/**
* Set the text in the UnicodeString object to the characters
- * in <TT>srcText</TT> in the range
+ * in <TT>srcText</TT> in the range
* [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
* <TT>srcText</TT> is not modified.
* @param srcText the source for the new characters
* @return a reference to this
* @stable ICU 2.0
*/
- inline UnicodeString& setTo(const UnicodeString& srcText,
- int32_t srcStart,
+ inline UnicodeString& setTo(const UnicodeString& srcText,
+ int32_t srcStart,
int32_t srcLength);
/**
- * Set the text in the UnicodeString object to the characters in
- * <TT>srcText</TT>.
+ * Set the text in the UnicodeString object to the characters in
+ * <TT>srcText</TT>.
* <TT>srcText</TT> is not modified.
* @param srcText the source for the new characters
* @return a reference to this
/**
* Set the characters in the UnicodeString object to the code unit
* <TT>srcChar</TT>.
- * @param srcChar the code unit which becomes the UnicodeString's character
+ * @param srcChar the code unit which becomes the UnicodeString's character
* content
* @return a reference to this
* @stable ICU 2.0
/**
* Set the characters in the UnicodeString object to the code point
* <TT>srcChar</TT>.
- * @param srcChar the code point which becomes the UnicodeString's character
+ * @param srcChar the code point which becomes the UnicodeString's character
* content
* @return a reference to this
* @stable ICU 2.0
* @return A reference to this
* @stable ICU 2.0
*/
- UnicodeString& setCharAt(int32_t offset,
+ UnicodeString& setCharAt(int32_t offset,
UChar ch);
/**
* Append the characters
- * 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>
+ * 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>
* is not modified.
* @param srcText the source for the new characters
- * @param srcStart the offset into <TT>srcText</TT> where 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
+ * @param srcLength the number of characters in <TT>srcText</TT> in
* the append string
* @return a reference to this
* @stable ICU 2.0
*/
- inline UnicodeString& append(const UnicodeString& srcText,
- int32_t srcStart,
+ inline UnicodeString& append(const UnicodeString& srcText,
+ int32_t srcStart,
int32_t srcLength);
/**
- * Append the characters in <TT>srcText</TT> to the UnicodeString object at
+ * Append the characters in <TT>srcText</TT> to the UnicodeString object at
* offset <TT>start</TT>. <TT>srcText</TT> is not modified.
* @param srcText the source for the new characters
* @return a reference to this
inline UnicodeString& append(const UnicodeString& srcText);
/**
- * Append the characters in <TT>srcChars</TT> in the range
- * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) to the UnicodeString
- * object at offset
+ * Append the characters in <TT>srcChars</TT> in the range
+ * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) to the UnicodeString
+ * object at offset
* <TT>start</TT>. <TT>srcChars</TT> is not modified.
* @param srcChars the source for the new characters
- * @param srcStart the offset into <TT>srcChars</TT> where new characters
+ * @param srcStart the offset into <TT>srcChars</TT> where new characters
* will be obtained
- * @param srcLength the number of characters in <TT>srcChars</TT> in
+ * @param srcLength the number of characters in <TT>srcChars</TT> in
* the append string
* @return a reference to this
* @stable ICU 2.0
*/
- inline UnicodeString& append(const UChar *srcChars,
- int32_t srcStart,
+ inline UnicodeString& append(const UChar *srcChars,
+ int32_t srcStart,
int32_t srcLength);
/**
- * Append the characters in <TT>srcChars</TT> to the UnicodeString object
+ * Append the characters in <TT>srcChars</TT> to the UnicodeString object
* at offset <TT>start</TT>. <TT>srcChars</TT> is not modified.
* @param srcChars the source for the new characters
* @param srcLength the number of Unicode characters in <TT>srcChars</TT>
/* Insert operations */
/**
- * Insert the characters in <TT>srcText</TT> in the range
- * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) into the UnicodeString
+ * Insert the characters in <TT>srcText</TT> in the range
+ * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) into the UnicodeString
* object at offset <TT>start</TT>. <TT>srcText</TT> is not modified.
* @param start the offset where the insertion begins
- * @param srcText the source for the new characters
- * @param srcStart the offset into <TT>srcText</TT> where new characters
+ * @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
+ * @param srcLength the number of characters in <TT>srcText</TT> in
* the insert string
* @return a reference to this
* @stable ICU 2.0
*/
- inline UnicodeString& insert(int32_t start,
- const UnicodeString& srcText,
- int32_t srcStart,
+ inline UnicodeString& insert(int32_t start,
+ const UnicodeString& srcText,
+ int32_t srcStart,
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
- * @param srcText the source for the new characters
+ * @param srcText the source for the new characters
* @return a reference to this
* @stable ICU 2.0
*/
- inline UnicodeString& insert(int32_t start,
+ inline UnicodeString& insert(int32_t start,
const UnicodeString& srcText);
/**
- * Insert the characters in <TT>srcChars</TT> in the range
+ * Insert the characters in <TT>srcChars</TT> in the range
* [<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
- * @param srcStart the offset into <TT>srcChars</TT> where new characters
+ * @param srcStart the offset into <TT>srcChars</TT> where new characters
* will be obtained
- * @param srcLength the number of characters in <TT>srcChars</TT>
+ * @param srcLength the number of characters in <TT>srcChars</TT>
* in the insert string
* @return a reference to this
* @stable ICU 2.0
*/
- inline UnicodeString& insert(int32_t start,
- const UChar *srcChars,
- int32_t srcStart,
+ inline UnicodeString& insert(int32_t start,
+ const UChar *srcChars,
+ int32_t srcStart,
int32_t srcLength);
/**
- * Insert the characters in <TT>srcChars</TT> into the UnicodeString object
+ * Insert the characters in <TT>srcChars</TT> into the UnicodeString object
* 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
* @return a reference to this
* @stable ICU 2.0
*/
- inline UnicodeString& insert(int32_t start,
+ inline UnicodeString& insert(int32_t start,
const UChar *srcChars,
int32_t srcLength);
/**
- * Insert the code unit <TT>srcChar</TT> into the UnicodeString object at
+ * Insert the code unit <TT>srcChar</TT> into the UnicodeString object at
* offset <TT>start</TT>.
* @param start the offset at which the insertion occurs
* @param srcChar the code unit to insert
* @return a reference to this
* @stable ICU 2.0
*/
- inline UnicodeString& insert(int32_t start,
+ inline UnicodeString& insert(int32_t start,
UChar srcChar);
/**
- * Insert the code point <TT>srcChar</TT> into the UnicodeString object at
+ * Insert the code point <TT>srcChar</TT> into the UnicodeString object at
* 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
* @stable ICU 2.0
*/
- inline UnicodeString& insert(int32_t start,
+ inline UnicodeString& insert(int32_t start,
UChar32 srcChar);
/* Replace operations */
/**
- * 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>).
+ * 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>).
* <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
+ * @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
- * @param srcStart the offset into <TT>srcText</TT> where 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
+ * @param srcLength the number of characters in <TT>srcText</TT> in
* the replace string
* @return a reference to this
* @stable ICU 2.0
*/
- UnicodeString& replace(int32_t start,
- int32_t length,
- const UnicodeString& srcText,
- int32_t srcStart,
+ UnicodeString& replace(int32_t start,
+ int32_t length,
+ const UnicodeString& srcText,
+ int32_t srcStart,
int32_t srcLength);
/**
- * Replace the characters in the range
- * [<TT>start</TT>, <TT>start + length</TT>)
+ * Replace the characters in the range
+ * [<TT>start</TT>, <TT>start + length</TT>)
* with the characters in <TT>srcText</TT>. <TT>srcText</TT> is
* not modified.
* @param start the offset at which the replace operation begins
* @return a reference to this
* @stable ICU 2.0
*/
- UnicodeString& replace(int32_t start,
- int32_t length,
+ UnicodeString& replace(int32_t start,
+ int32_t length,
const UnicodeString& srcText);
/**
- * 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>
+ * 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>
* is not modified.
* @param start the offset at which the replace operation begins
* @param length the number of characters to replace. The character at
* @param srcChars the source for the new characters
* @param srcStart the offset into <TT>srcChars</TT> where new characters
* will be obtained
- * @param srcLength the number of characters in <TT>srcChars</TT>
+ * @param srcLength the number of characters in <TT>srcChars</TT>
* in the replace string
* @return a reference to this
* @stable ICU 2.0
*/
- UnicodeString& replace(int32_t start,
- int32_t length,
- const UChar *srcChars,
- int32_t srcStart,
+ UnicodeString& replace(int32_t start,
+ int32_t length,
+ const UChar *srcChars,
+ int32_t srcStart,
int32_t srcLength);
/**
- * Replace the characters in the range
+ * Replace the characters in the range
* [<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
* @return a reference to this
* @stable ICU 2.0
*/
- inline UnicodeString& replace(int32_t start,
- int32_t length,
+ inline UnicodeString& replace(int32_t start,
+ int32_t length,
const UChar *srcChars,
int32_t srcLength);
/**
- * Replace the characters in the range
+ * Replace the characters in the range
* [<TT>start</TT>, <TT>start + length</TT>) with the code unit
* <TT>srcChar</TT>.
* @param start the offset at which the replace operation begins
* @return a reference to this
* @stable ICU 2.0
*/
- inline UnicodeString& replace(int32_t start,
- int32_t length,
+ inline UnicodeString& replace(int32_t start,
+ int32_t length,
UChar srcChar);
/**
- * Replace the characters in the range
+ * Replace the characters in the range
* [<TT>start</TT>, <TT>start + length</TT>) with the code point
* <TT>srcChar</TT>.
* @param start the offset at which the replace operation begins
* @return a reference to this
* @stable ICU 2.0
*/
- inline UnicodeString& replace(int32_t start,
- int32_t length,
+ inline UnicodeString& replace(int32_t start,
+ int32_t length,
UChar32 srcChar);
/**
- * Replace the characters in the range [<TT>start</TT>, <TT>limit</TT>)
+ * Replace the characters in the range [<TT>start</TT>, <TT>limit</TT>)
* 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
* @return a reference to this
* @stable ICU 2.0
*/
- inline UnicodeString& replaceBetween(int32_t start,
- int32_t limit,
+ inline UnicodeString& replaceBetween(int32_t start,
+ int32_t limit,
const UnicodeString& srcText);
/**
- * Replace the characters in the range [<TT>start</TT>, <TT>limit</TT>)
- * with the characters in <TT>srcText</TT> in the range
+ * Replace the characters 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>). <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
- * @param srcStart the offset into <TT>srcChars</TT> where new characters
+ * @param srcStart the offset into <TT>srcChars</TT> where new characters
* will be obtained
- * @param srcLimit the offset immediately following the range to copy
+ * @param srcLimit the offset immediately following the range to copy
* in <TT>srcText</TT>
* @return a reference to this
* @stable ICU 2.0
*/
- inline UnicodeString& replaceBetween(int32_t start,
- int32_t limit,
- const UnicodeString& srcText,
- int32_t srcStart,
+ inline UnicodeString& replaceBetween(int32_t start,
+ int32_t limit,
+ const UnicodeString& srcText,
+ int32_t srcStart,
int32_t srcLimit);
/**
/**
* Replaceable API
* @return TRUE if it has MetaData
- * @draft ICU 2.4
+ * @stable ICU 2.4
*/
virtual UBool hasMetaData() const;
-
+
/**
* 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.
- *
+ *
* @param start the beginning index, inclusive; <code>0 <= start <=
* limit</code>.
* @param limit the ending index, exclusive; <code>start <= limit <=
/* Search and replace operations */
/**
- * Replace all occurrences of characters in oldText with the characters
+ * Replace all occurrences of characters in oldText with the characters
* in newText
* @param oldText the text containing the search text
* @param newText the text containing the replacement text
const UnicodeString& newText);
/**
- * Replace all occurrences of characters in oldText with characters
+ * Replace all occurrences of characters in oldText with characters
* in newText
* in the range [<TT>start</TT>, <TT>start + length</TT>).
* @param start the start of the range in which replace will performed
const UnicodeString& newText);
/**
- * 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>)
+ * 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>)
* 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
inline UnicodeString& remove(void);
/**
- * Remove the characters in the range
+ * Remove the characters in the range
* [<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
* @stable ICU 2.0
*/
- inline UnicodeString& remove(int32_t start,
+ inline UnicodeString& remove(int32_t start,
int32_t length = (int32_t)INT32_MAX);
/**
- * Remove the characters in the range
+ * Remove the characters in the range
* [<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
/* Length operations */
/**
- * Pad the start of this UnicodeString with the character <TT>padChar</TT>.
- * If the length of this UnicodeString is less than targetLength,
+ * Pad the start of this UnicodeString with the character <TT>padChar</TT>.
+ * If the length of this UnicodeString is less than targetLength,
* length() - targetLength copies of padChar will be added to the
* beginning of this UnicodeString.
* @param targetLength the desired length of the string
- * @param padChar the character to use for padding. Defaults to
+ * @param padChar the character to use for padding. Defaults to
* space (U+0020)
* @return TRUE if the text was padded, FALSE otherwise.
* @stable ICU 2.0
UChar padChar = 0x0020);
/**
- * Pad the end of this UnicodeString with the character <TT>padChar</TT>.
- * If the length of this UnicodeString is less than targetLength,
+ * Pad the end of this UnicodeString with the character <TT>padChar</TT>.
+ * If the length of this UnicodeString is less than targetLength,
* length() - targetLength copies of padChar will be added to the
* end of this UnicodeString.
* @param targetLength the desired length of the string
- * @param padChar the character to use for padding. Defaults to
+ * @param padChar the character to use for padding. Defaults to
* space (U+0020)
* @return TRUE if the text was padded, FALSE otherwise.
* @stable ICU 2.0
* 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.
* @return A reference to this.
* @stable ICU 2.1
*/
* 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.
* @return A reference to this.
* @stable ICU 2.1
*
* @see getBuffer(int32_t minCapacity)
* @see getBuffer()
- * @draft ICU 2.2
+ * @stable ICU 2.2
*/
inline const UChar *getTerminatedBuffer();
// Constructors
//========================================
- /** Construct an empty UnicodeString.
+ /** Construct an empty UnicodeString.
* @stable ICU 2.0
*/
UnicodeString();
*/
UnicodeString(UChar *buffer, int32_t buffLength, int32_t buffCapacity);
+#if !UCONFIG_NO_CONVERSION
+
/**
* char* constructor.
* @param codepageData an array of bytes, null-terminated
* @param codepage the encoding of <TT>codepageData</TT>. The special
- * value 0 for <TT>codepage</TT> indicates that the text is in the
+ * value 0 for <TT>codepage</TT> indicates that the text is in the
* 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.
+ * 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.
+ *
* @stable ICU 2.0
*/
UnicodeString(const char *codepageData,
* @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
- * value 0 for <TT>codepage</TT> indicates that the text is in the
+ * value 0 for <TT>codepage</TT> indicates that the text is in the
* 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.
+ * 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.
+ *
* @stable ICU 2.0
*/
UnicodeString(const char *codepageData,
UConverter *cnv,
UErrorCode &errorCode);
+#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
+ * @draft ICU 3.2
+ */
+ UnicodeString(const char *src, int32_t length, enum EInvariant inv);
+
/**
* Copy constructor.
* '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.
- * @draft ICU2.2
+ * @stable ICU 2.2
*/
UnicodeString(const UnicodeString& src, int32_t srcStart);
* @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.
- * @draft ICU2.2
+ * @stable ICU 2.2
*/
UnicodeString(const UnicodeString& src, int32_t srcStart, int32_t srcLength);
*
* @see Replaceable::clone
* @see getDynamicClassID
- * @draft ICU 2.6
+ * @stable ICU 2.6
*/
virtual Replaceable *clone() const;
- /** Destructor.
+ /** Destructor.
* @stable ICU 2.0
*/
- ~UnicodeString();
+ virtual ~UnicodeString();
/* Miscellaneous operations */
* Unescape a string of characters and return a string containing
* the result. The following escape sequences are recognized:
*
- * \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
+ * \\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
*
* as well as the standard ANSI C escapes:
*
- * \a => U+0007, \b => U+0008, \t => U+0009, \n => U+000A,
- * \v => U+000B, \f => U+000C, \r => U+000D, \e => U+001B,
- * \" => U+0022, \' => U+0027, \? => U+003F, \\ => U+005C
+ * \\a => U+0007, \\b => U+0008, \\t => U+0009, \\n => U+000A,
+ * \\v => U+000B, \\f => U+000C, \\r => U+000D, \\e => U+001B,
+ * \\" => U+0022, \\' => U+0027, \\? => U+003F, \\\\ => U+005C
*
* Anything else following a backslash is generically escaped. For
- * example, "[a\-z]" returns "[a-z]".
+ * example, "[a\\-z]" returns "[a-z]".
*
* If an escape sequence is ill-formed, this method returns an empty
- * string. An example of an ill-formed sequence is "\u" followed by
+ * string. An example of an ill-formed sequence is "\\u" followed by
* fewer than 4 hex digits.
*
* This function is similar to u_unescape() but not identical to it.
UChar32 unescapeAt(int32_t &offset) const;
/**
- * ICU "poor man's RTTI", returns a UClassID for the actual class.
+ * ICU "poor man's RTTI", returns a UClassID for this class.
*
- * @draft ICU 2.2
+ * @stable ICU 2.2
*/
- virtual inline UClassID getDynamicClassID() const;
+ static UClassID U_EXPORT2 getStaticClassID();
/**
- * ICU "poor man's RTTI", returns a UClassID for this class.
+ * ICU "poor man's RTTI", returns a UClassID for the actual class.
*
- * @draft ICU 2.2
+ * @stable ICU 2.2
*/
- static inline UClassID getStaticClassID();
+ virtual UClassID getDynamicClassID() const;
//========================================
// Implementation methods
protected:
/**
* Implement Replaceable::getLength() (see jitterbug 1027).
- * @draft ICU 2.4
+ * @stable ICU 2.4
*/
virtual int32_t getLength() const;
/**
* The change in Replaceable to use virtual getCharAt() allows
* UnicodeString::charAt() to be inline again (see jitterbug 709).
- * @draft ICU 2.4
+ * @stable ICU 2.4
*/
virtual UChar getCharAt(int32_t offset) const;
/**
* The change in Replaceable to use virtual getChar32At() allows
* UnicodeString::char32At() to be inline again (see jitterbug 709).
- * @draft ICU 2.4
+ * @stable ICU 2.4
*/
virtual UChar32 getChar32At(int32_t offset) const;
int32_t start,
int32_t length) const;
- void doExtract(int32_t start,
- int32_t length,
- UChar *dst,
+ void doExtract(int32_t start,
+ int32_t length,
+ UChar *dst,
int32_t dstStart) const;
inline void doExtract(int32_t start,
inline UChar doCharAt(int32_t offset) const;
- UnicodeString& doReplace(int32_t start,
- int32_t length,
- const UnicodeString& srcText,
- int32_t srcStart,
+ UnicodeString& doReplace(int32_t start,
+ int32_t length,
+ const UnicodeString& srcText,
+ int32_t srcStart,
int32_t srcLength);
- UnicodeString& doReplace(int32_t start,
- int32_t length,
- const UChar *srcChars,
- int32_t srcStart,
+ UnicodeString& doReplace(int32_t start,
+ int32_t length,
+ const UChar *srcChars,
+ int32_t srcStart,
int32_t srcLength);
UnicodeString& doReverse(int32_t start,
inline void pinIndices(int32_t& start,
int32_t& length) const;
+#if !UCONFIG_NO_CONVERSION
+
/* Internal extract() using UConverter. */
int32_t doExtract(int32_t start, int32_t length,
char *dest, int32_t destCapacity,
int32_t dataLength,
UConverter *converter,
UErrorCode &status);
+
+#endif
+
/*
* This function is called when write access to the array
* is necessary.
// common function for case mappings
UnicodeString &
caseMap(BreakIterator *titleIter,
- const Locale& locale,
+ const char *locale,
uint32_t options,
int32_t toWhichCase);
uint16_t fFlags; // bit flags: see constants above
UChar fStackBuffer [ US_STACKBUF_SIZE ]; // buffer for small strings
- /**
- * The address of this static class variable serves as this class's ID
- * for ICU "poor man's RTTI".
- */
- static const char fgClassID;
};
+/**
+ * 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)
+ * @draft ICU 2.8
+ */
+U_COMMON_API UnicodeString U_EXPORT2
+operator+ (const UnicodeString &s1, const UnicodeString &s2);
+
U_NAMESPACE_END
+// inline implementations -------------------------------------------------- ***
+
//========================================
// Array copying
//========================================
* Copy an array of UnicodeString OBJECTS (not pointers).
* @internal
*/
-inline void
+inline void
uprv_arrayCopy(const U_NAMESPACE_QUALIFIER UnicodeString *src, U_NAMESPACE_QUALIFIER UnicodeString *dst, int32_t count)
{ while(count-- > 0) *dst++ = *src++; }
* Copy an array of UnicodeString OBJECTS (not pointers).
* @internal
*/
-inline void
-uprv_arrayCopy(const U_NAMESPACE_QUALIFIER UnicodeString *src, int32_t srcStart,
+inline void
+uprv_arrayCopy(const U_NAMESPACE_QUALIFIER UnicodeString *src, int32_t srcStart,
U_NAMESPACE_QUALIFIER UnicodeString *dst, int32_t dstStart, int32_t count)
{ uprv_arrayCopy(src+srcStart, dst+dstStart, count); }
}
}
-inline UChar*
+inline UChar*
UnicodeString::getArrayStart()
{ return fArray; }
-inline const UChar*
+inline const UChar*
UnicodeString::getArrayStart() const
{ return fArray; }
//========================================
// Read-only implementation methods
//========================================
-inline UClassID
-UnicodeString::getStaticClassID()
-{ return (UClassID)&fgClassID; }
-
-inline UClassID
-UnicodeString::getDynamicClassID() const
-{ return UnicodeString::getStaticClassID(); }
-
-inline int32_t
+inline int32_t
UnicodeString::length() const
{ return fLength; }
-inline int32_t
+inline int32_t
UnicodeString::getCapacity() const
{ return fCapacity; }
-inline int32_t
+inline int32_t
UnicodeString::hashCode() const
{ return doHashCode(); }
-inline UBool
+inline UBool
UnicodeString::isBogus() const
{ return (UBool)(fFlags & kIsBogus); }
UnicodeString::operator<= (const UnicodeString& text) const
{ return doCompare(0, fLength, text, 0, text.fLength) != 1; }
-inline int8_t
+inline int8_t
UnicodeString::compare(const UnicodeString& text) const
{ return doCompare(0, fLength, text, 0, text.fLength); }
-inline int8_t
+inline int8_t
UnicodeString::compare(int32_t start,
int32_t _length,
const UnicodeString& srcText) const
{ return doCompare(start, _length, srcText, 0, srcText.fLength); }
-inline int8_t
+inline int8_t
UnicodeString::compare(const UChar *srcChars,
int32_t srcLength) const
{ return doCompare(0, fLength, srcChars, 0, srcLength); }
-inline int8_t
+inline int8_t
UnicodeString::compare(int32_t start,
int32_t _length,
const UnicodeString& srcText,
const UChar *srcChars) const
{ return doCompare(start, _length, srcChars, 0, _length); }
-inline int8_t
+inline int8_t
UnicodeString::compare(int32_t start,
int32_t _length,
const UChar *srcChars,
const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLimit) const
-{ return doCompare(start, limit - start,
+{ return doCompare(start, limit - start,
srcText, srcStart, srcLimit - srcStart); }
inline int8_t
}
}
-inline int8_t
+inline int8_t
UnicodeString::compareCodePointOrder(const UnicodeString& text) const
{ return doCompareCodePointOrder(0, fLength, text, 0, text.fLength); }
-inline int8_t
+inline int8_t
UnicodeString::compareCodePointOrder(int32_t start,
int32_t _length,
const UnicodeString& srcText) const
{ return doCompareCodePointOrder(start, _length, srcText, 0, srcText.fLength); }
-inline int8_t
+inline int8_t
UnicodeString::compareCodePointOrder(const UChar *srcChars,
int32_t srcLength) const
{ return doCompareCodePointOrder(0, fLength, srcChars, 0, srcLength); }
-inline int8_t
+inline int8_t
UnicodeString::compareCodePointOrder(int32_t start,
int32_t _length,
const UnicodeString& srcText,
const UChar *srcChars) const
{ return doCompareCodePointOrder(start, _length, srcChars, 0, _length); }
-inline int8_t
+inline int8_t
UnicodeString::compareCodePointOrder(int32_t start,
int32_t _length,
const UChar *srcChars,
const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLimit) const
-{ return doCompareCodePointOrder(start, limit - start,
+{ return doCompareCodePointOrder(start, limit - start,
srcText, srcStart, srcLimit - srcStart); }
inline int8_t
}
}
-inline int8_t
+inline int8_t
UnicodeString::caseCompare(const UnicodeString &text, uint32_t options) const {
return doCaseCompare(0, fLength, text, 0, text.fLength, options);
}
-inline int8_t
+inline int8_t
UnicodeString::caseCompare(int32_t start,
int32_t _length,
const UnicodeString &srcText,
return doCaseCompare(start, _length, srcText, 0, srcText.fLength, options);
}
-inline int8_t
+inline int8_t
UnicodeString::caseCompare(const UChar *srcChars,
int32_t srcLength,
uint32_t options) const {
return doCaseCompare(0, fLength, srcChars, 0, srcLength, options);
}
-inline int8_t
+inline int8_t
UnicodeString::caseCompare(int32_t start,
int32_t _length,
const UnicodeString &srcText,
return doCaseCompare(start, _length, srcChars, 0, _length, options);
}
-inline int8_t
+inline int8_t
UnicodeString::caseCompare(int32_t start,
int32_t _length,
const UChar *srcChars,
return doCaseCompare(start, limit - start, srcText, srcStart, srcLimit - srcStart, options);
}
-inline int32_t
+inline int32_t
UnicodeString::indexOf(const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength,
return -1;
}
-inline int32_t
+inline int32_t
UnicodeString::indexOf(const UnicodeString& text) const
{ return indexOf(text, 0, text.fLength, 0, fLength); }
-inline int32_t
+inline int32_t
UnicodeString::indexOf(const UnicodeString& text,
int32_t start) const {
pinIndex(start);
return indexOf(text, 0, text.fLength, start, fLength - start);
}
-inline int32_t
+inline int32_t
UnicodeString::indexOf(const UnicodeString& text,
int32_t start,
int32_t _length) const
{ return indexOf(text, 0, text.fLength, start, _length); }
-inline int32_t
+inline int32_t
UnicodeString::indexOf(const UChar *srcChars,
int32_t srcLength,
int32_t start) const {
return indexOf(srcChars, 0, srcLength, start, fLength - start);
}
-inline int32_t
+inline int32_t
UnicodeString::indexOf(const UChar *srcChars,
int32_t srcLength,
int32_t start,
int32_t _length) const
{ return indexOf(srcChars, 0, srcLength, start, _length); }
-inline int32_t
+inline int32_t
UnicodeString::indexOf(UChar c,
int32_t start,
int32_t _length) const
{ return doIndexOf(c, start, _length); }
-inline int32_t
+inline int32_t
UnicodeString::indexOf(UChar32 c,
int32_t start,
int32_t _length) const
{ return doIndexOf(c, start, _length); }
-inline int32_t
+inline int32_t
UnicodeString::indexOf(UChar c) const
{ return doIndexOf(c, 0, fLength); }
-inline int32_t
+inline int32_t
UnicodeString::indexOf(UChar32 c) const
{ return indexOf(c, 0, fLength); }
-inline int32_t
+inline int32_t
UnicodeString::indexOf(UChar c,
int32_t start) const {
pinIndex(start);
return doIndexOf(c, start, fLength - start);
}
-inline int32_t
+inline int32_t
UnicodeString::indexOf(UChar32 c,
int32_t start) const {
pinIndex(start);
return indexOf(c, start, fLength - start);
}
-inline int32_t
+inline int32_t
UnicodeString::lastIndexOf(const UChar *srcChars,
int32_t srcLength,
int32_t start,
int32_t _length) const
{ return lastIndexOf(srcChars, 0, srcLength, start, _length); }
-inline int32_t
+inline int32_t
UnicodeString::lastIndexOf(const UChar *srcChars,
int32_t srcLength,
int32_t start) const {
return lastIndexOf(srcChars, 0, srcLength, start, fLength - start);
}
-inline int32_t
+inline int32_t
UnicodeString::lastIndexOf(const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength,
return -1;
}
-inline int32_t
+inline int32_t
UnicodeString::lastIndexOf(const UnicodeString& text,
int32_t start,
int32_t _length) const
{ return lastIndexOf(text, 0, text.fLength, start, _length); }
-inline int32_t
+inline int32_t
UnicodeString::lastIndexOf(const UnicodeString& text,
int32_t start) const {
pinIndex(start);
return lastIndexOf(text, 0, text.fLength, start, fLength - start);
}
-inline int32_t
+inline int32_t
UnicodeString::lastIndexOf(const UnicodeString& text) const
{ return lastIndexOf(text, 0, text.fLength, 0, fLength); }
-inline int32_t
+inline int32_t
UnicodeString::lastIndexOf(UChar c,
int32_t start,
int32_t _length) const
{ return doLastIndexOf(c, start, _length); }
-inline int32_t
+inline int32_t
UnicodeString::lastIndexOf(UChar32 c,
int32_t start,
int32_t _length) const {
return doLastIndexOf(c, start, _length);
}
-inline int32_t
+inline int32_t
UnicodeString::lastIndexOf(UChar c) const
{ return doLastIndexOf(c, 0, fLength); }
-inline int32_t
+inline int32_t
UnicodeString::lastIndexOf(UChar32 c) const {
return lastIndexOf(c, 0, fLength);
}
-inline int32_t
+inline int32_t
UnicodeString::lastIndexOf(UChar c,
int32_t start) const {
pinIndex(start);
return doLastIndexOf(c, start, fLength - start);
}
-inline int32_t
+inline int32_t
UnicodeString::lastIndexOf(UChar32 c,
int32_t start) const {
pinIndex(start);
return lastIndexOf(c, start, fLength - start);
}
-inline UBool
+inline UBool
UnicodeString::startsWith(const UnicodeString& text) const
{ return compare(0, text.fLength, text, 0, text.fLength) == 0; }
-inline UBool
+inline UBool
UnicodeString::startsWith(const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength) const
{ return doCompare(0, srcLength, srcText, srcStart, srcLength) == 0; }
-inline UBool
+inline UBool
UnicodeString::startsWith(const UChar *srcChars,
int32_t srcLength) const
{ return doCompare(0, srcLength, srcChars, 0, srcLength) == 0; }
-inline UBool
+inline UBool
UnicodeString::startsWith(const UChar *srcChars,
int32_t srcStart,
int32_t srcLength) const
{ return doCompare(0, srcLength, srcChars, srcStart, srcLength) == 0;}
-inline UBool
+inline UBool
UnicodeString::endsWith(const UnicodeString& text) const
-{ return doCompare(fLength - text.fLength, text.fLength,
+{ return doCompare(fLength - text.fLength, text.fLength,
text, 0, text.fLength) == 0; }
-inline UBool
+inline UBool
UnicodeString::endsWith(const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength) const {
srcText.pinIndices(srcStart, srcLength);
- return doCompare(fLength - srcLength, srcLength,
+ return doCompare(fLength - srcLength, srcLength,
srcText, srcStart, srcLength) == 0;
}
-inline UBool
+inline UBool
UnicodeString::endsWith(const UChar *srcChars,
int32_t srcLength) const {
if(srcLength < 0) {
srcLength = u_strlen(srcChars);
}
- return doCompare(fLength - srcLength, srcLength,
+ return doCompare(fLength - srcLength, srcLength,
srcChars, 0, srcLength) == 0;
}
-inline UBool
+inline UBool
UnicodeString::endsWith(const UChar *srcChars,
int32_t srcStart,
int32_t srcLength) const {
if(srcLength < 0) {
srcLength = u_strlen(srcChars + srcStart);
}
- return doCompare(fLength - srcLength, srcLength,
+ return doCompare(fLength - srcLength, srcLength,
srcChars, srcStart, srcLength) == 0;
}
//========================================
// replace
//========================================
-inline UnicodeString&
-UnicodeString::replace(int32_t start,
- int32_t _length,
- const UnicodeString& srcText)
+inline UnicodeString&
+UnicodeString::replace(int32_t start,
+ int32_t _length,
+ const UnicodeString& srcText)
{ return doReplace(start, _length, srcText, 0, srcText.fLength); }
-inline UnicodeString&
-UnicodeString::replace(int32_t start,
- int32_t _length,
- const UnicodeString& srcText,
- int32_t srcStart,
+inline UnicodeString&
+UnicodeString::replace(int32_t start,
+ int32_t _length,
+ const UnicodeString& srcText,
+ int32_t srcStart,
int32_t srcLength)
{ return doReplace(start, _length, srcText, srcStart, srcLength); }
-inline UnicodeString&
-UnicodeString::replace(int32_t start,
- int32_t _length,
+inline UnicodeString&
+UnicodeString::replace(int32_t start,
+ int32_t _length,
const UChar *srcChars,
int32_t srcLength)
{ return doReplace(start, _length, srcChars, 0, srcLength); }
-inline UnicodeString&
-UnicodeString::replace(int32_t start,
- int32_t _length,
- const UChar *srcChars,
- int32_t srcStart,
+inline UnicodeString&
+UnicodeString::replace(int32_t start,
+ int32_t _length,
+ const UChar *srcChars,
+ int32_t srcStart,
int32_t srcLength)
{ return doReplace(start, _length, srcChars, srcStart, srcLength); }
-inline UnicodeString&
-UnicodeString::replace(int32_t start,
- int32_t _length,
+inline UnicodeString&
+UnicodeString::replace(int32_t start,
+ int32_t _length,
UChar srcChar)
{ return doReplace(start, _length, &srcChar, 0, 1); }
inline UnicodeString&
-UnicodeString::replace(int32_t start,
- int32_t _length,
+UnicodeString::replace(int32_t start,
+ int32_t _length,
UChar32 srcChar) {
UChar buffer[U16_MAX_LENGTH];
int32_t count = 0;
return doReplace(start, _length, buffer, 0, count);
}
-inline UnicodeString&
-UnicodeString::replaceBetween(int32_t start,
- int32_t limit,
+inline UnicodeString&
+UnicodeString::replaceBetween(int32_t start,
+ int32_t limit,
const UnicodeString& srcText)
{ return doReplace(start, limit - start, srcText, 0, srcText.fLength); }
inline UnicodeString&
-UnicodeString::replaceBetween(int32_t start,
- int32_t limit,
- const UnicodeString& srcText,
- int32_t srcStart,
+UnicodeString::replaceBetween(int32_t start,
+ int32_t limit,
+ const UnicodeString& srcText,
+ int32_t srcStart,
int32_t srcLimit)
{ return doReplace(start, limit - start, srcText, srcStart, srcLimit - srcStart); }
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::findAndReplace(const UnicodeString& oldText,
const UnicodeString& newText)
-{ return findAndReplace(0, fLength, oldText, 0, oldText.fLength,
+{ return findAndReplace(0, fLength, oldText, 0, oldText.fLength,
newText, 0, newText.fLength); }
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::findAndReplace(int32_t start,
int32_t _length,
const UnicodeString& oldText,
const UnicodeString& newText)
-{ return findAndReplace(start, _length, oldText, 0, oldText.fLength,
+{ return findAndReplace(start, _length, oldText, 0, oldText.fLength,
newText, 0, newText.fLength); }
// ============================
UnicodeString& target) const
{ target.replace(0, target.fLength, *this, start, _length); }
-inline void
-UnicodeString::extract(int32_t start,
- int32_t _length,
- UChar *target,
+inline void
+UnicodeString::extract(int32_t start,
+ int32_t _length,
+ UChar *target,
int32_t targetStart) const
{ doExtract(start, _length, target, targetStart); }
-inline void
+inline void
UnicodeString::extract(int32_t start,
int32_t _length,
UnicodeString& target) const
{ doExtract(start, _length, target); }
+#if !UCONFIG_NO_CONVERSION
+
inline int32_t
UnicodeString::extract(int32_t start,
int32_t _length,
return extract(start, _length, dst, dst!=0 ? 0xffffffff : 0, codepage);
}
-inline void
-UnicodeString::extractBetween(int32_t start,
- int32_t limit,
- UChar *dst,
- int32_t dstStart) const
-{ doExtract(start, limit - start, dst, dstStart); }
+#endif
+
+inline void
+UnicodeString::extractBetween(int32_t start,
+ int32_t limit,
+ UChar *dst,
+ int32_t dstStart) const {
+ pinIndex(start);
+ pinIndex(limit);
+ doExtract(start, limit - start, dst, dstStart);
+}
inline UChar
UnicodeString::doCharAt(int32_t offset) const
}
}
-inline UnicodeString&
-UnicodeString::operator= (UChar ch)
+inline UnicodeString&
+UnicodeString::operator= (UChar ch)
{ return doReplace(0, fLength, &ch, 0, 1); }
-inline UnicodeString&
-UnicodeString::operator= (UChar32 ch)
+inline UnicodeString&
+UnicodeString::operator= (UChar32 ch)
{ return replace(0, fLength, ch); }
-inline UnicodeString&
-UnicodeString::setTo(const UnicodeString& srcText,
- int32_t srcStart,
+inline UnicodeString&
+UnicodeString::setTo(const UnicodeString& srcText,
+ int32_t srcStart,
int32_t srcLength)
{
unBogus();
return doReplace(0, fLength, srcText, srcStart, srcLength);
}
-inline UnicodeString&
-UnicodeString::setTo(const UnicodeString& srcText,
+inline UnicodeString&
+UnicodeString::setTo(const UnicodeString& srcText,
int32_t srcStart)
{
unBogus();
return doReplace(0, fLength, srcText, srcStart, srcText.fLength - srcStart);
}
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::setTo(const UnicodeString& srcText)
{
unBogus();
return doReplace(0, fLength, srcText, 0, srcText.fLength);
}
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::setTo(const UChar *srcChars,
int32_t srcLength)
{
return doReplace(0, fLength, srcChars, 0, srcLength);
}
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::setTo(UChar srcChar)
{
unBogus();
return doReplace(0, fLength, &srcChar, 0, 1);
}
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::setTo(UChar32 srcChar)
{
unBogus();
return replace(0, fLength, srcChar);
}
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::operator+= (UChar ch)
{ return doReplace(fLength, 0, &ch, 0, 1); }
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::operator+= (UChar32 ch) {
UChar buffer[U16_MAX_LENGTH];
int32_t _length = 0;
return doReplace(fLength, 0, buffer, 0, _length);
}
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::operator+= (const UnicodeString& srcText)
{ return doReplace(fLength, 0, srcText, 0, srcText.fLength); }
-inline UnicodeString&
-UnicodeString::append(const UnicodeString& srcText,
- int32_t srcStart,
+inline UnicodeString&
+UnicodeString::append(const UnicodeString& srcText,
+ int32_t srcStart,
int32_t srcLength)
{ return doReplace(fLength, 0, srcText, srcStart, srcLength); }
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::append(const UnicodeString& srcText)
{ return doReplace(fLength, 0, srcText, 0, srcText.fLength); }
-inline UnicodeString&
-UnicodeString::append(const UChar *srcChars,
- int32_t srcStart,
+inline UnicodeString&
+UnicodeString::append(const UChar *srcChars,
+ int32_t srcStart,
int32_t srcLength)
{ return doReplace(fLength, 0, srcChars, srcStart, srcLength); }
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::append(const UChar *srcChars,
int32_t srcLength)
{ return doReplace(fLength, 0, srcChars, 0, srcLength); }
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::append(UChar srcChar)
{ return doReplace(fLength, 0, &srcChar, 0, 1); }
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::append(UChar32 srcChar) {
UChar buffer[U16_MAX_LENGTH];
int32_t _length = 0;
return doReplace(fLength, 0, buffer, 0, _length);
}
-inline UnicodeString&
-UnicodeString::insert(int32_t start,
- const UnicodeString& srcText,
- int32_t srcStart,
+inline UnicodeString&
+UnicodeString::insert(int32_t start,
+ const UnicodeString& srcText,
+ int32_t srcStart,
int32_t srcLength)
{ return doReplace(start, 0, srcText, srcStart, srcLength); }
-inline UnicodeString&
-UnicodeString::insert(int32_t start,
+inline UnicodeString&
+UnicodeString::insert(int32_t start,
const UnicodeString& srcText)
{ return doReplace(start, 0, srcText, 0, srcText.fLength); }
-inline UnicodeString&
-UnicodeString::insert(int32_t start,
- const UChar *srcChars,
- int32_t srcStart,
+inline UnicodeString&
+UnicodeString::insert(int32_t start,
+ const UChar *srcChars,
+ int32_t srcStart,
int32_t srcLength)
{ return doReplace(start, 0, srcChars, srcStart, srcLength); }
-inline UnicodeString&
-UnicodeString::insert(int32_t start,
+inline UnicodeString&
+UnicodeString::insert(int32_t start,
const UChar *srcChars,
int32_t srcLength)
{ return doReplace(start, 0, srcChars, 0, srcLength); }
-inline UnicodeString&
-UnicodeString::insert(int32_t start,
+inline UnicodeString&
+UnicodeString::insert(int32_t start,
UChar srcChar)
{ return doReplace(start, 0, &srcChar, 0, 1); }
-inline UnicodeString&
-UnicodeString::insert(int32_t start,
+inline UnicodeString&
+UnicodeString::insert(int32_t start,
UChar32 srcChar)
{ return replace(start, 0, srcChar); }
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::remove()
{
// remove() of a bogus string makes the string empty and non-bogus
return *this;
}
-inline UnicodeString&
-UnicodeString::remove(int32_t start,
+inline UnicodeString&
+UnicodeString::remove(int32_t start,
int32_t _length)
{
if(start <= 0 && _length == INT32_MAX) {
}
}
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::removeBetween(int32_t start,
int32_t limit)
{ return doReplace(start, limit - start, NULL, 0, 0); }
-inline UBool
+inline UBool
UnicodeString::truncate(int32_t targetLength)
{
if(isBogus() && targetLength == 0) {
}
}
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::reverse()
{ return doReverse(0, fLength); }
-inline UnicodeString&
+inline UnicodeString&
UnicodeString::reverse(int32_t start,
int32_t _length)
{ return doReverse(start, _length); }
-
U_NAMESPACE_END
#endif