Nui
Loading...
Searching...
No Matches
utf.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <utf8.h>
4
5#include <iterator>
6
7namespace Nui
8{
9 namespace Detail
10 {
11 template <typename T>
12 concept IsStringCharTypeUtf16Compatible = requires(T str) {
13 typename T::value_type;
14 requires(sizeof(typename T::value_type) > 1);
15 };
16
17 template <typename T>
18 concept IsStringCharTypeUtf8Compatible = requires(T str) {
19 typename T::value_type;
20 requires(sizeof(typename T::value_type) == 1);
21 };
22 }
23
24 template <typename Utf16StringType, typename Utf8StringType>
27 Utf16StringType utf8ToUtf16(Utf8StringType const& str)
28 {
29 Utf16StringType result;
30 utf8::utf8to16(str.begin(), str.end(), std::back_inserter(result));
31 return result;
32 }
33
34 template <typename Utf16StringType, typename Utf8StringType>
37 Utf8StringType utf16ToUtf8(Utf16StringType const& str)
38 {
39 Utf8StringType result;
40 utf8::utf16to8(str.begin(), str.end(), std::back_inserter(result));
41 return result;
42 }
43}
static constexpr auto extractJsonMember(nlohmann::json const &json) -> decltype(auto)
Definition rpc_hub.hpp:29
Definition file_dialog.hpp:6
Utf8StringType utf16ToUtf8(Utf16StringType const &str)
Definition utf.hpp:37
Utf16StringType utf8ToUtf16(Utf8StringType const &str)
Definition utf.hpp:27