Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions icu4c/source/common/unicode/unistr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,9 @@ class U_COMMON_API UnicodeString : public Replaceable
* @return a read-only alias UnicodeString object for the substring
* @stable ICU 4.4
*/
UnicodeString tempSubString(int32_t start=0, int32_t length=INT32_MAX) const;
UnicodeString tempSubString(int32_t start=0, int32_t length=INT32_MAX) const &;

UnicodeString tempSubString(int32_t, int32_t) const && = delete;

/**
* Create a temporary substring for the specified range.
Expand All @@ -1749,7 +1751,9 @@ class U_COMMON_API UnicodeString : public Replaceable
* @param start offset of the first character visible in the substring
* @param limit offset immediately following the last character visible in the substring
* @return a read-only alias UnicodeString object for the substring
* @stable ICU 4.4
inline UnicodeString tempSubStringBetween(int32_t start, int32_t limit=INT32_MAX) const &;

inline UnicodeString tempSubStringBetween(int32_t, int32_t) const && = delete;
*/
inline UnicodeString tempSubStringBetween(int32_t start, int32_t limit=INT32_MAX) const;

Expand Down Expand Up @@ -4898,7 +4902,7 @@ UnicodeString::extractBetween(int32_t start,
}

inline UnicodeString
UnicodeString::tempSubStringBetween(int32_t start, int32_t limit) const {
UnicodeString::tempSubStringBetween(int32_t start, int32_t limit) const & {
return tempSubString(start, limit - start);
}

Expand Down
2 changes: 1 addition & 1 deletion icu4c/source/common/unistr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ UnicodeString::extract(int32_t start,
}

UnicodeString
UnicodeString::tempSubString(int32_t start, int32_t len) const {
UnicodeString::tempSubString(int32_t start, int32_t len) const &{
pinIndices(start, len);
const char16_t *array = getBuffer(); // not getArrayStart() to check kIsBogus & kOpenGetBuffer
if(array==nullptr) {
Expand Down
5 changes: 3 additions & 2 deletions icu4c/source/i18n/number_fluent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,11 @@ void LocalizedNumberFormatter::getAffixImpl(bool isPrefix, bool isNegative, Unic
prefixLength = NumberFormatterImpl::getPrefixSuffixStatic(fMacros, signum, plural, string, status);
}
result.remove();
const auto tempUnicodeString = string.toTempUnicodeString();
if (isPrefix) {
result.append(string.toTempUnicodeString().tempSubStringBetween(0, prefixLength));
result.append(tempUnicodeString.tempSubStringBetween(0, prefixLength));
} else {
result.append(string.toTempUnicodeString().tempSubStringBetween(prefixLength, string.length()));
result.append(tempUnicodeString.tempSubStringBetween(prefixLength, string.length()));
}
}

Expand Down