Nui
Loading...
Searching...
No Matches
nui
include
nui
utility
utf.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <utf8.h>
4
5
#include <iterator>
6
7
namespace
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>
25
requires
(
Detail::IsStringCharTypeUtf16Compatible<Utf16StringType>
) &&
26
(
Detail::IsStringCharTypeUtf8Compatible<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>
35
requires
(
Detail::IsStringCharTypeUtf16Compatible<Utf16StringType>
) &&
36
(
Detail::IsStringCharTypeUtf8Compatible<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
}
Nui::Detail::IsStringCharTypeUtf16Compatible
Definition
utf.hpp:12
Nui::Detail::IsStringCharTypeUtf8Compatible
Definition
utf.hpp:18
Nui::Detail::extractJsonMember
static constexpr auto extractJsonMember(nlohmann::json const &json) -> decltype(auto)
Definition
rpc_hub.hpp:29
Nui
Definition
file_dialog.hpp:6
Nui::utf16ToUtf8
Utf8StringType utf16ToUtf8(Utf16StringType const &str)
Definition
utf.hpp:37
Nui::utf8ToUtf16
Utf16StringType utf8ToUtf16(Utf8StringType const &str)
Definition
utf.hpp:27
Generated by
1.9.8