diff options
author | nae202 <nae202@yandex-team.com> | 2024-11-20 12:52:01 +0300 |
---|---|---|
committer | nae202 <nae202@yandex-team.com> | 2024-11-20 13:14:09 +0300 |
commit | 0b9d91e900b52bccd6eabd033acbb57c4ee173fc (patch) | |
tree | 6839ed69fbda4d5214eb418acc4554924bc64160 /util/charset/wide.h | |
parent | 878e26057d11cce46b7bc3a6c838209d4686e28b (diff) | |
download | ydb-0b9d91e900b52bccd6eabd033acbb57c4ee173fc.tar.gz |
Part of PR. Style
Часть большого ПР REVIEW:7264088
commit_hash:0f5b03fbbed0ac30f734943309e3ef5cd4d7a30e
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; } |