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