diff options
author | amnosov <amnosov@yandex-team.com> | 2022-10-26 11:59:40 +0300 |
---|---|---|
committer | amnosov <amnosov@yandex-team.com> | 2022-10-26 11:59:40 +0300 |
commit | 4225eab76862f099d4d55a0205ab0cdd39c0433c (patch) | |
tree | 842ff268488999a8f54243cfb10ba96fb333645b /library/cpp/unicode/set/quoted_pair.cpp | |
parent | 2399206380b6eab57bb7b9ad0bf0ecf851c94c1d (diff) | |
download | ydb-4225eab76862f099d4d55a0205ab0cdd39c0433c.tar.gz |
Unicode::Is{Category}
Unicode::Is{Category} udfs added
Diffstat (limited to 'library/cpp/unicode/set/quoted_pair.cpp')
-rw-r--r-- | library/cpp/unicode/set/quoted_pair.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/library/cpp/unicode/set/quoted_pair.cpp b/library/cpp/unicode/set/quoted_pair.cpp new file mode 100644 index 0000000000..7675dbaa74 --- /dev/null +++ b/library/cpp/unicode/set/quoted_pair.cpp @@ -0,0 +1,53 @@ +#include "quoted_pair.h" + +#include <util/generic/strbuf.h> + +namespace NUnicode { + EUnicodeQuotedPairType ResolveUnicodeQuotedPair(wchar32 escapedSymbol, wchar32& symbol, TUnicodeSet& set) { + switch (escapedSymbol) { + case wchar32('a'): // \a -> U+0007 Bell + symbol = wchar32('\a'); + return UQPT_SYMBOL; + case wchar32('b'): // \b -> U+0008 Backspace + symbol = wchar32('\b'); + return UQPT_SYMBOL; + case wchar32('t'): // \t -> U+0009 Horizontal Tab + symbol = wchar32('\t'); + return UQPT_SYMBOL; + case wchar32('n'): // \n -> U+000A Line Feed + symbol = wchar32('\n'); + return UQPT_SYMBOL; + case wchar32('v'): // \v -> U+000B Vertical Tab + symbol = wchar32('\v'); + return UQPT_SYMBOL; + case wchar32('f'): // \f -> U+000C Form Feed + symbol = wchar32('\f'); + return UQPT_SYMBOL; + case wchar32('r'): // \r -> U+000D Carriage Return + symbol = wchar32('\r'); + return UQPT_SYMBOL; + case wchar32('s'): + set.AddCategory(TStringBuf("Z")); + return UQPT_SET; + case wchar32('S'): + set.Add(TUnicodeSet().AddCategory(TStringBuf("Z")).Invert()); + return UQPT_SET; + case wchar32('w'): + set.AddCategory(TStringBuf("L")); + return UQPT_SET; + case wchar32('W'): + set.Add(TUnicodeSet().AddCategory(TStringBuf("L")).Invert()); + return UQPT_SET; + case wchar32('d'): + set.AddCategory(TStringBuf("Nd")); + return UQPT_SET; + case wchar32('D'): + set.Add(TUnicodeSet().AddCategory(TStringBuf("Nd")).Invert()); + return UQPT_SET; + default: + symbol = escapedSymbol; + return UQPT_SYMBOL; + } + } + +} |