Deskflow 1.25.0.128
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
Unicode.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
4 * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
5 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
6 */
7
8#pragma once
9
10#include <cstdint>
11#include <string>
12
14
19{
20public:
22
23
25
29 static bool isUTF8(const std::string &);
30
32
37 static std::string UTF8ToUCS2(const std::string &, bool *errors = nullptr);
38
40
45 static std::string UTF8ToUTF16(const std::string &, bool *errors = nullptr);
46
48
52 static std::string UCS2ToUTF8(const std::string_view &, bool *errors = nullptr);
53
55
59 static std::string UTF16ToUTF8(const std::string_view &, bool *errors = nullptr);
60
62
63private:
64 // internal conversion to UTF8
65 static std::string doUCS2ToUTF8(const uint8_t *src, uint32_t n, bool *errors);
66 static std::string doUTF16ToUTF8(const uint8_t *src, uint32_t n, bool *errors);
67
68 // convert characters to/from UTF8
69 static uint32_t fromUTF8(const uint8_t *&src, uint32_t &size);
70 static void toUTF8(std::string &dst, uint32_t c, bool *errors);
71
72private:
73 static uint32_t s_invalid;
74 static uint32_t s_replacement;
75};
Unicode utility functions.
Definition Unicode.h:19
static std::string UTF16ToUTF8(const std::string_view &, bool *errors=nullptr)
Convert from UTF-16 to UTF-8.
Definition Unicode.cpp:161
static bool isUTF8(const std::string &)
Test UTF-8 string for validity.
Definition Unicode.cpp:77
static std::string UTF8ToUTF16(const std::string &, bool *errors=nullptr)
Convert from UTF-8 to UTF-16 encoding.
Definition Unicode.cpp:116
static std::string UTF8ToUCS2(const std::string &, bool *errors=nullptr)
Convert from UTF-8 to UCS-2 encoding.
Definition Unicode.cpp:89
static std::string UCS2ToUTF8(const std::string_view &, bool *errors=nullptr)
Convert from UCS-2 to UTF-8.
Definition Unicode.cpp:151