Skip to content

Commit

Permalink
ICU-22901 Update ulocimp_getSubtags() &co. to use std::string_view.
Browse files Browse the repository at this point in the history
  • Loading branch information
roubert committed Nov 22, 2024
1 parent 1dccc10 commit 424d6a3
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 166 deletions.
4 changes: 3 additions & 1 deletion icu4c/source/common/locdispnames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* that then do not depend on resource bundle code and display name data.
*/

#include <string_view>

#include "unicode/utypes.h"
#include "unicode/brkiter.h"
#include "unicode/locid.h"
Expand Down Expand Up @@ -359,7 +361,7 @@ _getStringOrCopyKey(const char *path, const char *locale,
return u_terminateUChars(dest, destCapacity, length, &errorCode);
}

using UDisplayNameGetter = icu::CharString(const char*, UErrorCode&);
using UDisplayNameGetter = icu::CharString(std::string_view, UErrorCode&);

int32_t
_getDisplayNameForComponent(const char *locale,
Expand Down
4 changes: 2 additions & 2 deletions icu4c/source/common/loclikely.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ uloc_isRightToLeft(const char *locale) {
if (U_FAILURE(errorCode)) {
return false;
}
ulocimp_getSubtags(likely.data(), nullptr, &script, nullptr, nullptr, nullptr, errorCode);
ulocimp_getSubtags(likely.toStringPiece(), nullptr, &script, nullptr, nullptr, nullptr, errorCode);
if (U_FAILURE(errorCode) || script.isEmpty()) {
return false;
}
Expand Down Expand Up @@ -441,7 +441,7 @@ ulocimp_getRegionForSupplementalData(const char *localeID, bool inferRegion,
UErrorCode rgStatus = U_ZERO_ERROR;
icu::CharString locBuf = ulocimp_addLikelySubtags(localeID, rgStatus);
if (U_SUCCESS(rgStatus)) {
rgBuf = ulocimp_getRegion(locBuf.data(), status);
rgBuf = ulocimp_getRegion(locBuf.toStringPiece(), status);
}
}
}
Expand Down
Loading

0 comments on commit 424d6a3

Please sign in to comment.