+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
-* Copyright (C) 1999-2004, International Business Machines
+* Copyright (C) 1999-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: unistr_props.cpp
-* encoding: US-ASCII
+* encoding: UTF-8
* tab size: 8 (not used)
* indentation:2
*
#include "unicode/utypes.h"
#include "unicode/uchar.h"
#include "unicode/unistr.h"
+#include "unicode/utf16.h"
+
+U_NAMESPACE_BEGIN
UnicodeString&
UnicodeString::trim()
return *this;
}
+ UChar *array = getArrayStart();
UChar32 c;
- int32_t i = fLength, length;
+ int32_t oldLength = this->length();
+ int32_t i = oldLength, length;
// first cut off trailing white space
for(;;) {
if(i <= 0) {
break;
}
- UTF_PREV_CHAR(fArray, 0, i, c);
+ U16_PREV(array, 0, i, c);
if(!(c == 0x20 || u_isWhitespace(c))) {
break;
}
}
- if(length < fLength) {
- fLength = length;
+ if(length < oldLength) {
+ setLength(length);
}
// find leading white space
if(i >= length) {
break;
}
- UTF_NEXT_CHAR(fArray, i, length, c);
+ U16_NEXT(array, i, length, c);
if(!(c == 0x20 || u_isWhitespace(c))) {
break;
}
return *this;
}
+
+U_NAMESPACE_END