/src/icu/icu4c/source/common/fixedstring.cpp
Line | Count | Source |
1 | | // © 2025 and later: Unicode, Inc. and others. |
2 | | // License & terms of use: https://www.unicode.org/copyright.html |
3 | | |
4 | | #include "fixedstring.h" |
5 | | |
6 | | #include "unicode/unistr.h" |
7 | | #include "unicode/utypes.h" |
8 | | |
9 | | U_NAMESPACE_BEGIN |
10 | | |
11 | 60.9k | U_EXPORT void copyInvariantChars(const UnicodeString& src, FixedString& dst, UErrorCode& status) { |
12 | 60.9k | if (U_FAILURE(status)) { |
13 | 0 | return; |
14 | 0 | } |
15 | | |
16 | 60.9k | if (src.isEmpty()) { |
17 | 0 | dst.clear(); |
18 | 0 | return; |
19 | 0 | } |
20 | | |
21 | 60.9k | int32_t length = src.length(); |
22 | 60.9k | if (!dst.reserve(length + 1)) { |
23 | 0 | status = U_MEMORY_ALLOCATION_ERROR; |
24 | 0 | return; |
25 | 0 | } |
26 | 60.9k | src.extract(0, length, dst.getAlias(), length + 1, US_INV); |
27 | 60.9k | } |
28 | | |
29 | | U_NAMESPACE_END |