tetengo 1.8.2
A multipurpose library set
Loading...
Searching...
No Matches
utf16.hpp
Go to the documentation of this file.
1
7#if !defined(TETENGO_TEXT_ENCODING_UTF16_HPP)
8#define TETENGO_TEXT_ENCODING_UTF16_HPP
9
10#include <memory>
11#include <string>
12#include <string_view>
13
14#include <boost/core/noncopyable.hpp>
15
16
18{
22 class utf16 : private boost::noncopyable
23 {
24 public:
25 // types
26
28 using string_type = std::string;
29
31 using string_view_type = std::string_view;
32
34 using encoded_string_type = std::u16string;
35
37 using encoded_string_view_type = std::u16string_view;
38
39
40 // static functions
41
47 [[nodiscard]] static const utf16& instance();
48
49
50 // constructors and destructor
51
56
57
58 // functions
59
67 [[nodiscard]] encoded_string_type encode(const string_view_type& utf8) const;
68
76 [[nodiscard]] string_type decode(const encoded_string_view_type& string_) const;
77
78
79 private:
80 // types
81
82 class impl;
83
84
85 // variables
86
87 const std::unique_ptr<impl> m_p_impl;
88
89
90 // constructors
91
92 utf16();
93 };
94
95
96}
97
98
99#endif
A UTF-16 encoding.
Definition utf16.hpp:23
std::u16string_view encoded_string_view_type
The encoded string view type.
Definition utf16.hpp:37
std::u16string encoded_string_type
The encoded string type.
Definition utf16.hpp:34
string_type decode(const encoded_string_view_type &string_) const
Decodes a string in this encoding to UTF-8.
~utf16()
Destroys the encoding.
std::string string_type
The string type.
Definition utf16.hpp:28
static const utf16 & instance()
Returns the instance.
std::string_view string_view_type
The string view type.
Definition utf16.hpp:31
encoded_string_type encode(const string_view_type &utf8) const
Encodes a UTF-8 string to this encoding.
A UTF-8 encoding.
Definition utf8.hpp:22
String encodings.