xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
xtd.core
include
xtd
internal
__character_formatter.hpp
Go to the documentation of this file.
1
3
#pragma once
5
#if !defined(__XTD_CORE_INTERNAL__)
6
#error "Do not include this file: Internal use only"
7
#endif
9
10
#include "
../char32.hpp
"
11
#include <locale>
12
14
template
<
typename
char
_t,
typename
value_t>
15
[[nodiscard]]
inline
auto
__character_formatter(
const
std::basic_string<char_t>& fmt, value_t value,
const
std::locale& loc) -> std::basic_string<char_t> {
16
std::basic_string<char_t> result;
17
xtd::char32
codepoint =
static_cast<
xtd::char32
>
(
value
);
18
if
(codepoint < 0x80)
19
result.push_back(
static_cast<
char
>
(codepoint));
20
else
if
(codepoint < 0x800) {
21
result.push_back(
static_cast<
char
>
((codepoint >> 6) | 0xc0));
22
result.push_back(
static_cast<
char
>
((codepoint & 0x3f) | 0x80));
23
}
else
if
(codepoint < 0x10000) {
24
result.push_back(
static_cast<
char
>
((codepoint >> 12) | 0xe0));
25
result.push_back(
static_cast<
char
>
(((codepoint >> 6) & 0x3f) | 0x80));
26
result.push_back(
static_cast<
char
>
((codepoint & 0x3f) | 0x80));
27
}
else
{
28
result.push_back(
static_cast<
char
>
((codepoint >> 18) | 0xf0));
29
result.push_back(
static_cast<
char
>
(((codepoint >> 12) & 0x3f) | 0x80));
30
result.push_back(
static_cast<
char
>
(((codepoint >> 6) & 0x3f) | 0x80));
31
result.push_back(
static_cast<
char
>
((codepoint & 0x3f) | 0x80));
32
}
33
return
result;
34
}
char32.hpp
Contains xtd::char32 type.
xtd::expressions::operator_precedence::value
@ value
Represnets the constant operator precedence (42).
Definition
operator_precedence.hpp:30
xtd::char32
char32_t char32
Represents a 32-bit unicode character.
Definition
char32.hpp:23
Generated on
for xtd by
Gammasoft
. All rights reserved.