aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/Foundation/src/UnicodeConverter.cpp
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:44:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:49 +0300
commit718c552901d703c502ccbefdfc3c9028d608b947 (patch)
tree46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/libs/poco/Foundation/src/UnicodeConverter.cpp
parente9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff)
downloadydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/poco/Foundation/src/UnicodeConverter.cpp')
-rw-r--r--contrib/libs/poco/Foundation/src/UnicodeConverter.cpp320
1 files changed, 160 insertions, 160 deletions
diff --git a/contrib/libs/poco/Foundation/src/UnicodeConverter.cpp b/contrib/libs/poco/Foundation/src/UnicodeConverter.cpp
index 992c644c61..184330ba1a 100644
--- a/contrib/libs/poco/Foundation/src/UnicodeConverter.cpp
+++ b/contrib/libs/poco/Foundation/src/UnicodeConverter.cpp
@@ -1,161 +1,161 @@
-//
-// UnicodeConverter.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: UnicodeConverter
-//
-// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/UnicodeConverter.h"
-#include "Poco/TextConverter.h"
-#include "Poco/TextIterator.h"
-#include "Poco/UTF8Encoding.h"
-#include "Poco/UTF16Encoding.h"
-#include "Poco/UTF32Encoding.h"
-#include <cstring>
-
-
-namespace Poco {
-
-
-void UnicodeConverter::convert(const std::string& utf8String, UTF32String& utf32String)
-{
- utf32String.clear();
- UTF8Encoding utf8Encoding;
- TextIterator it(utf8String, utf8Encoding);
- TextIterator end(utf8String);
-
- while (it != end)
- {
- int cc = *it++;
- utf32String += (UTF32Char) cc;
- }
-}
-
-
-void UnicodeConverter::convert(const char* utf8String, std::size_t length, UTF32String& utf32String)
-{
- if (!utf8String || !length)
- {
- utf32String.clear();
- return;
- }
-
- convert(std::string(utf8String, utf8String + length), utf32String);
-}
-
-
-void UnicodeConverter::convert(const char* utf8String, UTF32String& utf32String)
-{
- if (!utf8String || !std::strlen(utf8String))
- {
- utf32String.clear();
- return;
- }
-
- convert(utf8String, std::strlen(utf8String), utf32String);
-}
-
-
-void UnicodeConverter::convert(const std::string& utf8String, UTF16String& utf16String)
-{
- utf16String.clear();
- UTF8Encoding utf8Encoding;
- TextIterator it(utf8String, utf8Encoding);
- TextIterator end(utf8String);
+//
+// UnicodeConverter.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: UnicodeConverter
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/UnicodeConverter.h"
+#include "Poco/TextConverter.h"
+#include "Poco/TextIterator.h"
+#include "Poco/UTF8Encoding.h"
+#include "Poco/UTF16Encoding.h"
+#include "Poco/UTF32Encoding.h"
+#include <cstring>
+
+
+namespace Poco {
+
+
+void UnicodeConverter::convert(const std::string& utf8String, UTF32String& utf32String)
+{
+ utf32String.clear();
+ UTF8Encoding utf8Encoding;
+ TextIterator it(utf8String, utf8Encoding);
+ TextIterator end(utf8String);
+
while (it != end)
- {
- int cc = *it++;
- if (cc <= 0xffff)
- {
- utf16String += (UTF16Char) cc;
- }
- else
- {
- cc -= 0x10000;
- utf16String += (UTF16Char) ((cc >> 10) & 0x3ff) | 0xd800;
- utf16String += (UTF16Char) (cc & 0x3ff) | 0xdc00;
- }
- }
-}
-
-
-void UnicodeConverter::convert(const char* utf8String, std::size_t length, UTF16String& utf16String)
-{
- if (!utf8String || !length)
- {
- utf16String.clear();
- return;
- }
-
- convert(std::string(utf8String, utf8String + length), utf16String);
-}
-
-
-void UnicodeConverter::convert(const char* utf8String, UTF16String& utf16String)
-{
- if (!utf8String || !std::strlen(utf8String))
- {
- utf16String.clear();
- return;
- }
-
- convert(std::string(utf8String), utf16String);
-}
-
-
-void UnicodeConverter::convert(const UTF16String& utf16String, std::string& utf8String)
-{
- utf8String.clear();
- UTF8Encoding utf8Encoding;
- UTF16Encoding utf16Encoding;
- TextConverter converter(utf16Encoding, utf8Encoding);
- converter.convert(utf16String.data(), (int) utf16String.length() * sizeof(UTF16Char), utf8String);
-}
-
-
-void UnicodeConverter::convert(const UTF32String& utf32String, std::string& utf8String)
-{
- utf8String.clear();
- UTF8Encoding utf8Encoding;
- UTF32Encoding utf32Encoding;
- TextConverter converter(utf32Encoding, utf8Encoding);
- converter.convert(utf32String.data(), (int) utf32String.length() * sizeof(UTF32Char), utf8String);
-}
-
-
-void UnicodeConverter::convert(const UTF16Char* utf16String, std::size_t length, std::string& utf8String)
-{
- utf8String.clear();
- UTF8Encoding utf8Encoding;
- UTF16Encoding utf16Encoding;
- TextConverter converter(utf16Encoding, utf8Encoding);
- converter.convert(utf16String, (int) length * sizeof(UTF16Char), utf8String);
-}
-
-
-void UnicodeConverter::convert(const UTF32Char* utf32String, std::size_t length, std::string& utf8String)
-{
- toUTF8(UTF32String(utf32String, length), utf8String);
-}
-
-
-void UnicodeConverter::convert(const UTF16Char* utf16String, std::string& utf8String)
-{
- toUTF8(utf16String, UTFStrlen(utf16String), utf8String);
-}
-
-
-void UnicodeConverter::convert(const UTF32Char* utf32String, std::string& utf8String)
-{
- toUTF8(utf32String, UTFStrlen(utf32String), utf8String);
-}
-
-
-} // namespace Poco
+ {
+ int cc = *it++;
+ utf32String += (UTF32Char) cc;
+ }
+}
+
+
+void UnicodeConverter::convert(const char* utf8String, std::size_t length, UTF32String& utf32String)
+{
+ if (!utf8String || !length)
+ {
+ utf32String.clear();
+ return;
+ }
+
+ convert(std::string(utf8String, utf8String + length), utf32String);
+}
+
+
+void UnicodeConverter::convert(const char* utf8String, UTF32String& utf32String)
+{
+ if (!utf8String || !std::strlen(utf8String))
+ {
+ utf32String.clear();
+ return;
+ }
+
+ convert(utf8String, std::strlen(utf8String), utf32String);
+}
+
+
+void UnicodeConverter::convert(const std::string& utf8String, UTF16String& utf16String)
+{
+ utf16String.clear();
+ UTF8Encoding utf8Encoding;
+ TextIterator it(utf8String, utf8Encoding);
+ TextIterator end(utf8String);
+ while (it != end)
+ {
+ int cc = *it++;
+ if (cc <= 0xffff)
+ {
+ utf16String += (UTF16Char) cc;
+ }
+ else
+ {
+ cc -= 0x10000;
+ utf16String += (UTF16Char) ((cc >> 10) & 0x3ff) | 0xd800;
+ utf16String += (UTF16Char) (cc & 0x3ff) | 0xdc00;
+ }
+ }
+}
+
+
+void UnicodeConverter::convert(const char* utf8String, std::size_t length, UTF16String& utf16String)
+{
+ if (!utf8String || !length)
+ {
+ utf16String.clear();
+ return;
+ }
+
+ convert(std::string(utf8String, utf8String + length), utf16String);
+}
+
+
+void UnicodeConverter::convert(const char* utf8String, UTF16String& utf16String)
+{
+ if (!utf8String || !std::strlen(utf8String))
+ {
+ utf16String.clear();
+ return;
+ }
+
+ convert(std::string(utf8String), utf16String);
+}
+
+
+void UnicodeConverter::convert(const UTF16String& utf16String, std::string& utf8String)
+{
+ utf8String.clear();
+ UTF8Encoding utf8Encoding;
+ UTF16Encoding utf16Encoding;
+ TextConverter converter(utf16Encoding, utf8Encoding);
+ converter.convert(utf16String.data(), (int) utf16String.length() * sizeof(UTF16Char), utf8String);
+}
+
+
+void UnicodeConverter::convert(const UTF32String& utf32String, std::string& utf8String)
+{
+ utf8String.clear();
+ UTF8Encoding utf8Encoding;
+ UTF32Encoding utf32Encoding;
+ TextConverter converter(utf32Encoding, utf8Encoding);
+ converter.convert(utf32String.data(), (int) utf32String.length() * sizeof(UTF32Char), utf8String);
+}
+
+
+void UnicodeConverter::convert(const UTF16Char* utf16String, std::size_t length, std::string& utf8String)
+{
+ utf8String.clear();
+ UTF8Encoding utf8Encoding;
+ UTF16Encoding utf16Encoding;
+ TextConverter converter(utf16Encoding, utf8Encoding);
+ converter.convert(utf16String, (int) length * sizeof(UTF16Char), utf8String);
+}
+
+
+void UnicodeConverter::convert(const UTF32Char* utf32String, std::size_t length, std::string& utf8String)
+{
+ toUTF8(UTF32String(utf32String, length), utf8String);
+}
+
+
+void UnicodeConverter::convert(const UTF16Char* utf16String, std::string& utf8String)
+{
+ toUTF8(utf16String, UTFStrlen(utf16String), utf8String);
+}
+
+
+void UnicodeConverter::convert(const UTF32Char* utf32String, std::string& utf8String)
+{
+ toUTF8(utf32String, UTFStrlen(utf32String), utf8String);
+}
+
+
+} // namespace Poco