/* ******************************************************************************* * * Copyright (C) 2009-2010, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: filterednormalizer2.cpp * encoding: US-ASCII * tab size: 8 (not used) * indentation:4 * * created on: 2009dec10 * created by: Markus W. Scherer */ #include "unicode/utypes.h" #if !UCONFIG_NO_NORMALIZATION #include "unicode/normalizer2.h" #include "unicode/uniset.h" #include "unicode/unistr.h" #include "unicode/unorm.h" #include "cpputils.h" U_NAMESPACE_BEGIN UnicodeString & FilteredNormalizer2::normalize(const UnicodeString &src, UnicodeString &dest, UErrorCode &errorCode) const { uprv_checkCanGetBuffer(src, errorCode); if(U_FAILURE(errorCode)) { dest.setToBogus(); return dest; } if(&dest==&src) { errorCode=U_ILLEGAL_ARGUMENT_ERROR; return dest; } dest.remove(); return normalize(src, dest, USET_SPAN_SIMPLE, errorCode); } // Internal: No argument checking, and appends to dest. // Pass as input spanCondition the one that is likely to yield a non-zero // span length at the start of src. // For set=[:age=3.2:], since almost all common characters were in Unicode 3.2, // USET_SPAN_SIMPLE should be passed in for the start of src // and USET_SPAN_NOT_CONTAINED should be passed in if we continue after // an in-filter prefix. UnicodeString & FilteredNormalizer2::normalize(const UnicodeString &src, UnicodeString &dest, USetSpanCondition spanCondition, UErrorCode &errorCode) const { UnicodeString tempDest; // Don't throw away destination buffer between iterations. for(int32_t prevSpanLimit=0; prevSpanLimit