aboutsummaryrefslogtreecommitdiffstats
path: root/util/charset/wide.h
diff options
context:
space:
mode:
authorMaxim Yurchuk <maxim-yurchuk@ydb.tech>2024-11-20 17:37:57 +0000
committerGitHub <noreply@github.com>2024-11-20 17:37:57 +0000
commitf76323e9b295c15751e51e3443aa47a36bee8023 (patch)
tree4113c8cad473a33e0f746966e0cf087252fa1d7a /util/charset/wide.h
parent753ecb8d410a4cb459c26f3a0082fb2d1724fe63 (diff)
parenta7b9a6afea2a9d7a7bfac4c5eb4c1a8e60adb9e6 (diff)
downloadydb-f76323e9b295c15751e51e3443aa47a36bee8023.tar.gz
Merge pull request #11788 from ydb-platform/mergelibs-241120-1113
Library import 241120-1113
Diffstat (limited to 'util/charset/wide.h')
-rw-r--r--util/charset/wide.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/util/charset/wide.h b/util/charset/wide.h
index c2a8d00372..4792a65953 100644
--- a/util/charset/wide.h
+++ b/util/charset/wide.h
@@ -81,8 +81,9 @@ inline const wchar32* SkipSymbol(const wchar32* begin, const wchar32* end) noexc
inline wchar32 ReadSymbol(const wchar16* begin, const wchar16* end) noexcept {
Y_ASSERT(begin < end);
if (IsW16SurrogateLead(*begin)) {
- if (begin + 1 < end && IsW16SurrogateTail(*(begin + 1)))
+ if (begin + 1 < end && IsW16SurrogateTail(*(begin + 1))) {
return ::NDetail::ReadSurrogatePair(begin);
+ }
return BROKEN_RUNE;
} else if (IsW16SurrogateTail(*begin)) {
@@ -210,8 +211,9 @@ inline bool WriteSymbol(wchar32 s, wchar16*& dest, const wchar16* destEnd) noexc
return true;
}
- if (dest + 2 > destEnd)
+ if (dest + 2 > destEnd) {
return false;
+ }
::NDetail::WriteSurrogatePair(s, dest);
} else {
@@ -362,8 +364,9 @@ inline TUtf16String UTF8ToWide(const char* text, size_t len) {
TUtf16String w = TUtf16String::Uninitialized(len);
size_t written;
size_t pos = UTF8ToWideImpl<robust>(text, len, w.begin(), written);
- if (pos != len)
+ if (pos != len) {
ythrow yexception() << "failed to decode UTF-8 string at pos " << pos << ::NDetail::InStringMsg(text, len);
+ }
Y_ASSERT(w.size() >= written);
w.remove(written);
return w;
@@ -707,15 +710,17 @@ inline TUtf32String ASCIIToUTF32(const TStringBuf s) {
//! returns @c true if string contains whitespace characters only
inline bool IsSpace(const wchar16* s, size_t n) {
- if (n == 0)
+ if (n == 0) {
return false;
+ }
Y_ASSERT(s);
const wchar16* const e = s + n;
for (const wchar16* p = s; p != e; ++p) {
- if (!IsWhitespace(*p))
+ if (!IsWhitespace(*p)) {
return false;
+ }
}
return true;
}
@@ -879,8 +884,9 @@ inline bool IsValidUTF16(const wchar16* b, const wchar16* e) {
Y_ENSURE(b <= e, TStringBuf("invalid iterators"));
while (b < e) {
wchar32 symbol = ReadSymbolAndAdvance(b, e);
- if (symbol == BROKEN_RUNE)
+ if (symbol == BROKEN_RUNE) {
return false;
+ }
}
return true;
}