diff options
author | Vlad Yaroslavlev <vladon@vladon.com> | 2022-02-10 16:46:25 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:25 +0300 |
commit | 344ea37b4a345701ab0e67de2266a1c1bd7baf2d (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/unicode | |
parent | 706b83ed7de5a473436620367af31fc0ceecde07 (diff) | |
download | ydb-344ea37b4a345701ab0e67de2266a1c1bd7baf2d.tar.gz |
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/unicode')
-rw-r--r-- | library/cpp/unicode/normalization/normalization.h | 2 | ||||
-rw-r--r-- | library/cpp/unicode/normalization/ut/normalization_ut.cpp | 4 | ||||
-rw-r--r-- | library/cpp/unicode/punycode/punycode.cpp | 14 | ||||
-rw-r--r-- | library/cpp/unicode/punycode/punycode.h | 22 | ||||
-rw-r--r-- | library/cpp/unicode/punycode/punycode_ut.cpp | 30 |
5 files changed, 36 insertions, 36 deletions
diff --git a/library/cpp/unicode/normalization/normalization.h b/library/cpp/unicode/normalization/normalization.h index bce2759dc1..4f5f57881c 100644 --- a/library/cpp/unicode/normalization/normalization.h +++ b/library/cpp/unicode/normalization/normalization.h @@ -127,7 +127,7 @@ namespace NUnicode { }; typedef std::pair<wchar32, TCombining> TSymbol; - typedef TVector<TSymbol> TBuffer; + typedef TVector<TSymbol> TBuffer; template <bool doCompose> class TCompositor; diff --git a/library/cpp/unicode/normalization/ut/normalization_ut.cpp b/library/cpp/unicode/normalization/ut/normalization_ut.cpp index dbccd0810d..54d4940a26 100644 --- a/library/cpp/unicode/normalization/ut/normalization_ut.cpp +++ b/library/cpp/unicode/normalization/ut/normalization_ut.cpp @@ -8,8 +8,8 @@ Y_UNIT_TEST_SUITE(TUnicodeNormalizationTest) { template <NUnicode::ENormalization NormType> void TestInit() { NUnicode::TNormalizer<NormType> normalizer; - TString s("упячка detected"); - TUtf16String w; + TString s("упячка detected"); + TUtf16String w; UTF8ToWide(s, w); normalizer.Normalize(w); } diff --git a/library/cpp/unicode/punycode/punycode.cpp b/library/cpp/unicode/punycode/punycode.cpp index 4a8993a95b..800d1f19fe 100644 --- a/library/cpp/unicode/punycode/punycode.cpp +++ b/library/cpp/unicode/punycode/punycode.cpp @@ -39,7 +39,7 @@ static inline void AppendUtf32ToWide(const ui32* in, size_t len, TUtf16String& o } } -TStringBuf WideToPunycode(const TWtringBuf& in16, TString& out) { +TStringBuf WideToPunycode(const TWtringBuf& in16, TString& out) { TVector<ui32> in32; AppendWideToUtf32(in16, in32); size_t outlen = in32.size(); @@ -57,7 +57,7 @@ TStringBuf WideToPunycode(const TWtringBuf& in16, TString& out) { return out; } -TWtringBuf PunycodeToWide(const TStringBuf& in, TUtf16String& out16) { +TWtringBuf PunycodeToWide(const TStringBuf& in, TUtf16String& out16) { size_t outlen = in.size(); TVector<ui32> out32(outlen); @@ -79,7 +79,7 @@ namespace { }; } -TString HostNameToPunycode(const TWtringBuf& unicodeHost) { +TString HostNameToPunycode(const TWtringBuf& unicodeHost) { TVector<ui32> in32; AppendWideToUtf32(unicodeHost, in32); in32.push_back(0); @@ -91,7 +91,7 @@ TString HostNameToPunycode(const TWtringBuf& unicodeHost) { return out.Data; } -TUtf16String PunycodeToHostName(const TStringBuf& punycodeHost) { +TUtf16String PunycodeToHostName(const TStringBuf& punycodeHost) { if (!IsStringASCII(punycodeHost.begin(), punycodeHost.end())) ythrow TPunycodeError() << "Non-ASCII punycode input"; @@ -105,12 +105,12 @@ TUtf16String PunycodeToHostName(const TStringBuf& punycodeHost) { int rc = idna_to_unicode_4z4z(in32.begin(), &out.Data, 0); CheckIdnaResult(rc); - TUtf16String decoded; + TUtf16String decoded; AppendUtf32ToWide(out.Data, std::char_traits<ui32>::length(out.Data), decoded); return decoded; } -TString ForceHostNameToPunycode(const TWtringBuf& unicodeHost) { +TString ForceHostNameToPunycode(const TWtringBuf& unicodeHost) { try { return HostNameToPunycode(unicodeHost); } catch (const TPunycodeError&) { @@ -118,7 +118,7 @@ TString ForceHostNameToPunycode(const TWtringBuf& unicodeHost) { } } -TUtf16String ForcePunycodeToHostName(const TStringBuf& punycodeHost) { +TUtf16String ForcePunycodeToHostName(const TStringBuf& punycodeHost) { try { return PunycodeToHostName(punycodeHost); } catch (const TPunycodeError&) { diff --git a/library/cpp/unicode/punycode/punycode.h b/library/cpp/unicode/punycode/punycode.h index 868e473253..af4acc25c1 100644 --- a/library/cpp/unicode/punycode/punycode.h +++ b/library/cpp/unicode/punycode/punycode.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/generic/strbuf.h> #include <util/generic/yexception.h> @@ -9,17 +9,17 @@ // Raw strings encoder/decoder: does not prepend with ACE prefix ("xn--"), // does not limit input length. Throws TPunycodeError on any internal error. // Returned strbuf points to @out data. -TStringBuf WideToPunycode(const TWtringBuf& in, TString& out); -TWtringBuf PunycodeToWide(const TStringBuf& in, TUtf16String& out); +TStringBuf WideToPunycode(const TWtringBuf& in, TString& out); +TWtringBuf PunycodeToWide(const TStringBuf& in, TUtf16String& out); -inline TString WideToPunycode(const TWtringBuf& in) { - TString out; +inline TString WideToPunycode(const TWtringBuf& in) { + TString out; WideToPunycode(in, out); return out; } -inline TUtf16String PunycodeToWide(const TStringBuf& in) { - TUtf16String out; +inline TUtf16String PunycodeToWide(const TStringBuf& in) { + TUtf16String out; PunycodeToWide(in, out); return out; } @@ -29,12 +29,12 @@ inline TUtf16String PunycodeToWide(const TStringBuf& in) { // Labels containing non-ASCII characters are prefixed with ACE prefix ("xn--"). // Limits maximal encoded domain label length to IDNA_LABEL_MAX_LENGTH (255 by default). // Throws TPunycodeError on failure. -TString HostNameToPunycode(const TWtringBuf& unicodeHost); -TUtf16String PunycodeToHostName(const TStringBuf& punycodeHost); +TString HostNameToPunycode(const TWtringBuf& unicodeHost); +TUtf16String PunycodeToHostName(const TStringBuf& punycodeHost); // Robust versions: on failure return original input, converted to/from UTF8 -TString ForceHostNameToPunycode(const TWtringBuf& unicodeHost); -TUtf16String ForcePunycodeToHostName(const TStringBuf& punycodeHost); +TString ForceHostNameToPunycode(const TWtringBuf& unicodeHost); +TUtf16String ForcePunycodeToHostName(const TStringBuf& punycodeHost); // True if @host looks like punycode domain label sequence, // containing at least one ACE-prefixed label. diff --git a/library/cpp/unicode/punycode/punycode_ut.cpp b/library/cpp/unicode/punycode/punycode_ut.cpp index bb192169d7..97271cf0d8 100644 --- a/library/cpp/unicode/punycode/punycode_ut.cpp +++ b/library/cpp/unicode/punycode/punycode_ut.cpp @@ -11,10 +11,10 @@ namespace { } Y_UNIT_TEST_SUITE(TPunycodeTest) { - static bool TestRaw(const TString& utf8, const TString& punycode) { - TUtf16String unicode = UTF8ToWide(utf8); - TString buf1; - TUtf16String buf2; + static bool TestRaw(const TString& utf8, const TString& punycode) { + TUtf16String unicode = UTF8ToWide(utf8); + TString buf1; + TUtf16String buf2; return HasSameBuffer(WideToPunycode(unicode, buf1), buf1) && buf1 == punycode && HasSameBuffer(PunycodeToWide(punycode, buf2), buf2) && buf2 == unicode && WideToPunycode(unicode) == punycode && PunycodeToWide(punycode) == unicode; } @@ -48,25 +48,25 @@ Y_UNIT_TEST_SUITE(TPunycodeTest) { UNIT_ASSERT_EXCEPTION(PunycodeToWide("-"), TPunycodeError); { - TString longIn; + TString longIn; for (size_t i = 0; i < 1024; ++i) longIn += "Qй"; - TString longOut = "QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ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bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; UNIT_ASSERT(TestRaw(longIn, longOut)); } } - static bool TestHostName(const TString& utf8, const TString& punycode, bool canBePunycode = false) { - TUtf16String unicode = UTF8ToWide(utf8); - TString buf1; - TUtf16String buf2; + static bool TestHostName(const TString& utf8, const TString& punycode, bool canBePunycode = false) { + TUtf16String unicode = UTF8ToWide(utf8); + TString buf1; + TUtf16String buf2; //Cerr << "Testing " << utf8 << Endl; return HostNameToPunycode(unicode) == punycode && HostNameToPunycode(UTF8ToWide(punycode)) == punycode // repeated encoding should give same result && PunycodeToHostName(punycode) == unicode && CanBePunycodeHostName(punycode) == canBePunycode; } - static bool TestForced(const TString& bad) { + static bool TestForced(const TString& bad) { return ForceHostNameToPunycode(UTF8ToWide(bad)) == bad && ForcePunycodeToHostName(bad) == UTF8ToWide(bad); } @@ -89,25 +89,25 @@ Y_UNIT_TEST_SUITE(TPunycodeTest) { { // non-ascii - TString bad = "президент.рф"; + TString bad = "президент.рф"; UNIT_ASSERT_EXCEPTION(PunycodeToHostName("президент.рф"), TPunycodeError); UNIT_ASSERT(ForcePunycodeToHostName(bad) == UTF8ToWide(bad)); } { // too long domain label - TString bad(500, 'a'); + TString bad(500, 'a'); UNIT_ASSERT_EXCEPTION(HostNameToPunycode(UTF8ToWide(bad)), TPunycodeError); UNIT_ASSERT(TestForced(bad)); // but can decode it } { // already has ACE prefix - TString bad("xn--яндекс.xn--рф"); + TString bad("xn--яндекс.xn--рф"); UNIT_ASSERT_EXCEPTION(HostNameToPunycode(UTF8ToWide(bad)), TPunycodeError); UNIT_ASSERT(TestForced(bad)); } { // empty non-root domain is not allowed (?) - TString bad(".яндекс.рф"); + TString bad(".яндекс.рф"); UNIT_ASSERT_EXCEPTION(HostNameToPunycode(UTF8ToWide(bad)), TPunycodeError); UNIT_ASSERT(TestForced(bad)); } |