diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
commit | 31773f157bf8164364649b5f470f52dece0a4317 (patch) | |
tree | 33d0f7eef45303ab68cf08ab381ce5e5e36c5240 /util/charset/wide.h | |
parent | 2c7938962d8689e175574fc1e817c05049f27905 (diff) | |
parent | eff600952d5dfe17942f38f510a8ac2b203bb3a5 (diff) | |
download | ydb-31773f157bf8164364649b5f470f52dece0a4317.tar.gz |
Merge branch 'rightlib' into mergelibs-241120-1113
Diffstat (limited to 'util/charset/wide.h')
-rw-r--r-- | util/charset/wide.h | 18 |
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; } |