From 60dcad04364552175c49472b0e58fe0638ea881f Mon Sep 17 00:00:00 2001 From: Andy Heninger Date: Fri, 21 Aug 2015 17:32:53 +0000 Subject: [PATCH] ICU-11794 add uprv_isInvariantUnicodeString(), as requested by Markus X-SVN-Rev: 37794 --- icu4c/source/common/charstr.cpp | 2 +- icu4c/source/common/uinvchar.h | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/icu4c/source/common/charstr.cpp b/icu4c/source/common/charstr.cpp index 846a074feb..fd07bb6e59 100644 --- a/icu4c/source/common/charstr.cpp +++ b/icu4c/source/common/charstr.cpp @@ -105,7 +105,7 @@ CharString &CharString::appendInvariantChars(const UnicodeString &s, UErrorCode if(U_FAILURE(errorCode)) { return *this; } - if (!uprv_isInvariantUString(s.getBuffer(), s.length())) { + if (!uprv_isInvariantUnicodeString(s)) { errorCode = U_INVARIANT_CONVERSION_ERROR; return *this; } diff --git a/icu4c/source/common/uinvchar.h b/icu4c/source/common/uinvchar.h index f307bd6a62..1a9aa78d54 100644 --- a/icu4c/source/common/uinvchar.h +++ b/icu4c/source/common/uinvchar.h @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 1999-2010, International Business Machines +* Copyright (C) 1999-2015, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -21,6 +21,9 @@ #define __UINVCHAR_H__ #include "unicode/utypes.h" +#ifdef __cplusplus +#include "unicode/unistr.h" +#endif /** * Check if a char string only contains invariant characters. @@ -48,6 +51,22 @@ uprv_isInvariantString(const char *s, int32_t length); U_INTERNAL UBool U_EXPORT2 uprv_isInvariantUString(const UChar *s, int32_t length); +#ifdef __cplusplus + +/** + * Check if a UnicodeString only contains invariant characters. + * See utypes.h for details. + * + * @param s Input string. + * @return TRUE if s contains only invariant characters. + */ +U_INTERNAL inline UBool U_EXPORT2 +uprv_isInvariantUnicodeString(const icu::UnicodeString &s) { + return uprv_isInvariantUString(s.getBuffer(), s.length()); +} + +#endif /* __cplusplus */ + /** * \def U_UPPER_ORDINAL * Get the ordinal number of an uppercase invariant character