summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu/icu-xetex/common/unistr_props.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/icu/icu-xetex/common/unistr_props.cpp')
-rw-r--r--Build/source/libs/icu/icu-xetex/common/unistr_props.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/Build/source/libs/icu/icu-xetex/common/unistr_props.cpp b/Build/source/libs/icu/icu-xetex/common/unistr_props.cpp
new file mode 100644
index 00000000000..a82408a558a
--- /dev/null
+++ b/Build/source/libs/icu/icu-xetex/common/unistr_props.cpp
@@ -0,0 +1,72 @@
+/*
+*******************************************************************************
+*
+* Copyright (C) 1999-2006, International Business Machines
+* Corporation and others. All Rights Reserved.
+*
+*******************************************************************************
+* file name: unistr_props.cpp
+* encoding: US-ASCII
+* tab size: 8 (not used)
+* indentation:2
+*
+* created on: 2004aug25
+* created by: Markus W. Scherer
+*
+* Character property dependent functions moved here from unistr.cpp
+*/
+
+#include "unicode/utypes.h"
+#include "unicode/uchar.h"
+#include "unicode/unistr.h"
+
+U_NAMESPACE_BEGIN
+
+UnicodeString&
+UnicodeString::trim()
+{
+ if(isBogus()) {
+ return *this;
+ }
+
+ UChar32 c;
+ int32_t i = fLength, length;
+
+ // first cut off trailing white space
+ for(;;) {
+ length = i;
+ if(i <= 0) {
+ break;
+ }
+ UTF_PREV_CHAR(fArray, 0, i, c);
+ if(!(c == 0x20 || u_isWhitespace(c))) {
+ break;
+ }
+ }
+ if(length < fLength) {
+ fLength = length;
+ }
+
+ // find leading white space
+ int32_t start;
+ i = 0;
+ for(;;) {
+ start = i;
+ if(i >= length) {
+ break;
+ }
+ UTF_NEXT_CHAR(fArray, i, length, c);
+ if(!(c == 0x20 || u_isWhitespace(c))) {
+ break;
+ }
+ }
+
+ // move string forward over leading white space
+ if(start > 0) {
+ doReplace(0, start, 0, 0, 0);
+ }
+
+ return *this;
+}
+
+U_NAMESPACE_END