diff options
author | dobrokot <dobrokot@yandex-team.ru> | 2022-02-10 16:49:07 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:07 +0300 |
commit | 8d57b69dee81198a59c39e64704f7dc9f04b4fbf (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/charset | |
parent | 25d83bf841d8b3ce3886525078f1964ac3c293c5 (diff) | |
download | ydb-8d57b69dee81198a59c39e64704f7dc9f04b4fbf.tar.gz |
Restoring authorship annotation for <dobrokot@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/charset')
-rw-r--r-- | util/charset/generated/unidata.cpp | 4 | ||||
-rw-r--r-- | util/charset/ut/ya.make | 2 | ||||
-rw-r--r-- | util/charset/utf8_ut.cpp | 30 | ||||
-rw-r--r-- | util/charset/wide.h | 24 | ||||
-rw-r--r-- | util/charset/wide_ut.cpp | 4 |
5 files changed, 32 insertions, 32 deletions
diff --git a/util/charset/generated/unidata.cpp b/util/charset/generated/unidata.cpp index f8344a9724..6f5adbbc0a 100644 --- a/util/charset/generated/unidata.cpp +++ b/util/charset/generated/unidata.cpp @@ -5340,7 +5340,7 @@ namespace { namespace NUnidataTableGenerated { }, // P[614] }; // static const NUnicode::NPrivate::TUnidataTable::TValuePtr P[][32] - static const NUnicode::NPrivate::TUnidataTable::TValuePtr* const Indexes[] = { + static const NUnicode::NPrivate::TUnidataTable::TValuePtr* const Indexes[] = { P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12], P[13], P[14], P[15], P[16], P[17], P[18], P[19], P[20], P[21], P[22], P[23], P[24], P[25], P[26], P[27], P[28], P[29], P[30], P[31], P[32], P[33], P[34], P[35], P[36], P[37], P[38], P[39], P[37], P[40], P[41], P[42], P[43], P[44], P[45], P[46], @@ -7517,7 +7517,7 @@ namespace { namespace NUnidataTableGenerated { P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[360], P[614], - }; // static const NUnicode::NPrivate::TUnidataTable::TValuePtr* const Indexes[] + }; // static const NUnicode::NPrivate::TUnidataTable::TValuePtr* const Indexes[] static const size_t Size = 1114110; }} // namespace NUnidataTableGenerated diff --git a/util/charset/ut/ya.make b/util/charset/ut/ya.make index de47f72202..6526815e92 100644 --- a/util/charset/ut/ya.make +++ b/util/charset/ut/ya.make @@ -7,7 +7,7 @@ DATA(arcadia/util/charset/ut/utf8) SRCS( utf8_ut.cpp - wide_ut.cpp + wide_ut.cpp ) INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) diff --git a/util/charset/utf8_ut.cpp b/util/charset/utf8_ut.cpp index 115dac8271..9e68881cca 100644 --- a/util/charset/utf8_ut.cpp +++ b/util/charset/utf8_ut.cpp @@ -1,22 +1,22 @@ #include "utf8.h" -#include "wide.h" - +#include "wide.h" + #include <util/stream/file.h> #include <util/ysaveload.h> #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/testing/unittest/env.h> - + Y_UNIT_TEST_SUITE(TUtfUtilTest) { Y_UNIT_TEST(TestUTF8Len) { UNIT_ASSERT_EQUAL(GetNumberOfUTF8Chars("привет!"), 7); - } - + } + Y_UNIT_TEST(TestToLowerUtfString) { - UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8("xyz XYZ ПРИВЕТ!"), "xyz xyz привет!"); - + UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8("xyz XYZ ПРИВЕТ!"), "xyz xyz привет!"); + UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8(TStringBuf("xyz")), "xyz"); - + { TString s = "привет!"; TString q = "ПРИВЕТ!"; @@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) { UNIT_ASSERT(ToLowerUTF8Impl(s.data(), s.size(), tmp) == false); UNIT_ASSERT(ToLowerUTF8Impl(q.data(), q.size(), tmp) == true); } - + { const char* weird = "\xC8\xBE"; // 'Ⱦ', U+023E. strlen(weird)==2, strlen(tolower_utf8(weird)) is 3 const char* turkI = "İ"; //strlen("İ") == 2, strlen(tolower_utf8("İ") == 1 @@ -41,16 +41,16 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) { s += chars[k % N]; k /= N; } - + TUtf16String tmp = UTF8ToWide(s); tmp.to_lower(); - + UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8(s), WideToUTF8(tmp)); } numberOfVariants *= N; - } - } - } + } + } + } Y_UNIT_TEST(TestToUpperUtfString) { UNIT_ASSERT_VALUES_EQUAL(ToUpperUTF8("xyz XYZ привет!"), "XYZ XYZ ПРИВЕТ!"); @@ -123,4 +123,4 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) { wtextScalar.remove(wtextSSE.size()); UNIT_ASSERT(wtextScalar == wtextSSE); } -} +} diff --git a/util/charset/wide.h b/util/charset/wide.h index d9402f5f05..04e6928aab 100644 --- a/util/charset/wide.h +++ b/util/charset/wide.h @@ -811,21 +811,21 @@ TUtf32String ToTitleRet(const TUtf32StringBuf text, size_t pos = 0, size_t count // insertBr=true - replace '\r' and '\n' with "<BR>" template <bool insertBr> void EscapeHtmlChars(TUtf16String& str); - -//! returns number of characters in range. Handle surrogate pairs as one character. -inline size_t CountWideChars(const wchar16* b, const wchar16* e) { - size_t count = 0; + +//! returns number of characters in range. Handle surrogate pairs as one character. +inline size_t CountWideChars(const wchar16* b, const wchar16* e) { + size_t count = 0; Y_ENSURE(b <= e, TStringBuf("invalid iterators")); - while (b < e) { - b = SkipSymbol(b, e); + while (b < e) { + b = SkipSymbol(b, e); ++count; - } - return count; -} - + } + return count; +} + inline size_t CountWideChars(const TWtringBuf str) { - return CountWideChars(str.begin(), str.end()); -} + return CountWideChars(str.begin(), str.end()); +} //! checks whether the range is valid UTF-16 sequence inline bool IsValidUTF16(const wchar16* b, const wchar16* e) { diff --git a/util/charset/wide_ut.cpp b/util/charset/wide_ut.cpp index 6612d59aa0..d8f3233e73 100644 --- a/util/charset/wide_ut.cpp +++ b/util/charset/wide_ut.cpp @@ -545,8 +545,8 @@ void TConversionTest::TestGetNumOfUTF8Chars() { result = GetNumberOfUTF8Chars(utext, 1, n); UNIT_ASSERT(!result); UNIT_ASSERT(n == 0); - - UNIT_ASSERT_EQUAL(GetNumberOfUTF8Chars("привет!"), 7); + + UNIT_ASSERT_EQUAL(GetNumberOfUTF8Chars("привет!"), 7); } void TConversionTest::TestSubstrUTF8() { |