DotNetDupe
4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Toggle main menu visibility
Loading...
Searching...
No Matches
Char.cpp
Go to the documentation of this file.
1
#include "
pch.h
"
2
#include "
System/Char.h
"
3
#include <cwctype>
4
5
namespace
DotNetDupe
{
6
namespace
System
{
7
8
Char::Char
() : m_c(
'\0'
) { }
9
10
Char::Char
(
char32_t
c) {
11
m_c = c;
12
}
13
14
void
Char::operator=
(
char32_t
c) {
15
m_c = c;
16
}
17
18
bool
Char::Equals
(
char32_t
c)
const
{
19
return
m_c == c;
20
}
21
22
bool
Char::operator==
(
char32_t
c)
const
{
23
return
m_c == c;
24
}
25
26
double
Char::GetNumericValue
(
char32_t
c) {
27
if
(c >=
'0'
&& c <=
'9'
) {
28
return
c -
'0'
;
29
}
30
return
-1.0;
31
}
32
33
bool
Char::IsAscii
(
char32_t
c) {
34
return
(c <= 0x7f);
35
}
36
37
bool
Char::IsAsciiDigit
(
char32_t
c) {
38
return
c >=
'0'
&& c <=
'9'
;
39
}
40
41
bool
Char::IsAsciiHexDigit
(
char32_t
c) {
42
return
(c >=
'0'
&& c <=
'9'
) ||
43
(c >=
'A'
&& c <=
'F'
) ||
44
(c >=
'a'
&& c <=
'f'
);
45
}
46
47
bool
Char::IsAsciiHexDigitLower
(
char32_t
c) {
48
return
(c >=
'0'
&& c <=
'9'
) ||
49
(c >=
'a'
&& c <=
'f'
);
50
}
51
52
bool
Char::IsAsciiHexDigitUpper
(
char32_t
c) {
53
return
(c >=
'0'
&& c <=
'9'
) ||
54
(c >=
'A'
&& c <=
'F'
);
55
}
56
57
bool
Char::IsAsciiLetter
(
char32_t
c) {
58
return
(c >=
'A'
&& c <=
'Z'
) || (c >=
'a'
&& c <=
'z'
);
59
}
60
61
bool
Char::IsAsciiLetterLower
(
char32_t
c) {
62
return
(c >=
'a'
&& c <=
'z'
);
63
}
64
65
bool
Char::IsAsciiLetterOrDigit
(
char32_t
c) {
66
return
(c >=
'A'
&& c <=
'Z'
) ||
67
(c >=
'a'
&& c <=
'z'
) ||
68
(c >=
'0'
&& c <=
'9'
);
69
}
70
71
bool
Char::IsAsciiLetterUpper
(
char32_t
c) {
72
return
(c >=
'A'
&& c <=
'Z'
);
73
}
74
75
bool
Char::IsBetween
(
char32_t
c,
char32_t
minInclusive,
char32_t
maxInclusive) {
76
return
c >= minInclusive && c <= maxInclusive;
77
}
78
79
bool
Char::IsControl
(
char32_t
c) {
81
if
(c <= 0x1F || (c >= 0x7F && c <= 0x9F))
return
true
;
82
if
(c >= 0xFFFFFF7F && c <= 0xFFFFFF9F)
return
true
;
// Handling signed char cast
83
85
if
(c <= 0xFFFF)
return
std::iswcntrl(
static_cast<
wint_t
>
(c)) != 0;
86
return
(c >= 0xE0000 && c <= 0xE007F);
87
}
88
89
bool
Char::IsDigit
(
char32_t
c) {
91
if
(c <= 0xFFFF)
return
std::iswdigit(
static_cast<
wint_t
>
(c)) != 0;
92
return
(c >= 0x1D7CE && c <= 0x1D7FF);
93
}
94
95
bool
Char::IsLower
(
char32_t
c) {
97
if
(c <= 0xFFFF)
return
std::iswlower(
static_cast<
wint_t
>
(c)) != 0;
98
return
(c >= 0x10428 && c <= 0x1044F);
99
}
100
101
bool
Char::IsLetter
(
char32_t
c) {
103
if
(c >=
'A'
&& c <=
'Z'
)
return
true
;
104
if
(c >=
'a'
&& c <=
'z'
)
return
true
;
105
if
(c >= 0xC0 && c <= 0xD6)
return
true
;
106
if
(c >= 0xD8 && c <= 0xF6)
return
true
;
107
if
(c >= 0xF8 && c <= 0xFF)
return
true
;
108
110
if
(c <= 0xFFFF)
return
std::iswalpha(
static_cast<
wint_t
>
(c)) != 0;
111
return
(c >= 0x20000 && c <= 0x2A6DF);
112
}
113
114
bool
Char::IsLetterOrDigit
(
char32_t
c) {
116
if
(c <= 0xFFFF)
return
std::iswalnum(
static_cast<
wint_t
>
(c)) != 0;
117
return
IsLetter
(c) ||
IsDigit
(c);
118
}
119
120
char32_t
Char::ToLower
(
char32_t
c) {
122
if
(c >=
'A'
&& c <=
'Z'
)
return
c + 0x20;
123
if
(c >= 0xC0 && c <= 0xD6)
return
c + 0x20;
124
if
(c >= 0xD8 && c <= 0xDE)
return
c + 0x20;
125
127
if
(c <= 0xFFFF) {
128
wint_t lower = std::towlower(
static_cast<
wint_t
>
(c));
129
if
(lower !=
static_cast<
wint_t
>
(c))
return
static_cast<
char32_t
>
(lower);
130
}
131
if
(c >= 0x10400 && c <= 0x10427)
return
c + 0x28;
132
return
c;
133
}
134
135
bool
Char::IsNumber
(
char32_t
c) {
136
return
IsDigit
(c);
137
}
138
139
}
140
}
Char.h
Represents a Unicode character code point mirroring .NET System.Char.
DotNetDupe::System::Char::IsLetterOrDigit
static bool IsLetterOrDigit(char32_t c)
Definition
Char.cpp:114
DotNetDupe::System::Char::IsDigit
static bool IsDigit(char32_t c)
Definition
Char.cpp:89
DotNetDupe::System::Char::IsAsciiLetterUpper
static bool IsAsciiLetterUpper(char32_t c)
Definition
Char.cpp:71
DotNetDupe::System::Char::IsLetter
static bool IsLetter(char32_t c)
Definition
Char.cpp:101
DotNetDupe::System::Char::IsAscii
static bool IsAscii(char32_t c)
Indicates whether the specified character is categorized as an ASCII character (0x00 - 0x7F).
Definition
Char.cpp:33
DotNetDupe::System::Char::IsControl
static bool IsControl(char32_t c)
Definition
Char.cpp:79
DotNetDupe::System::Char::IsLower
static bool IsLower(char32_t c)
Definition
Char.cpp:95
DotNetDupe::System::Char::GetNumericValue
static double GetNumericValue(char32_t c)
Converts the specified numeric Unicode character to a double-precision floating point number.
Definition
Char.cpp:26
DotNetDupe::System::Char::Char
Char()
Initializes a new instance of the Char class with null character.
Definition
Char.cpp:8
DotNetDupe::System::Char::operator==
bool operator==(char32_t c) const
Definition
Char.cpp:22
DotNetDupe::System::Char::IsAsciiHexDigitLower
static bool IsAsciiHexDigitLower(char32_t c)
Definition
Char.cpp:47
DotNetDupe::System::Char::operator=
void operator=(char32_t c)
Definition
Char.cpp:14
DotNetDupe::System::Char::IsAsciiHexDigit
static bool IsAsciiHexDigit(char32_t c)
Definition
Char.cpp:41
DotNetDupe::System::Char::IsAsciiLetter
static bool IsAsciiLetter(char32_t c)
Definition
Char.cpp:57
DotNetDupe::System::Char::IsBetween
static bool IsBetween(char32_t c, char32_t minInclusive, char32_t maxInclusive)
Definition
Char.cpp:75
DotNetDupe::System::Char::IsAsciiDigit
static bool IsAsciiDigit(char32_t c)
Definition
Char.cpp:37
DotNetDupe::System::Char::IsAsciiLetterOrDigit
static bool IsAsciiLetterOrDigit(char32_t c)
Definition
Char.cpp:65
DotNetDupe::System::Char::Equals
bool Equals(char32_t c) const
Definition
Char.cpp:18
DotNetDupe::System::Char::IsNumber
static bool IsNumber(char32_t c)
Definition
Char.cpp:135
DotNetDupe::System::Char::IsAsciiLetterLower
static bool IsAsciiLetterLower(char32_t c)
Definition
Char.cpp:61
DotNetDupe::System::Char::IsAsciiHexDigitUpper
static bool IsAsciiHexDigitUpper(char32_t c)
Definition
Char.cpp:52
DotNetDupe::System::Char::ToLower
static char32_t ToLower(char32_t c)
Definition
Char.cpp:120
DotNetDupe::System
Definition
Action.h:11
DotNetDupe
Definition
IServiceCollection.h:7
pch.h
DotNetDupe
Char.cpp
Generated by
1.18.0