Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HexConverter.cs
Go to the documentation of this file.
1
using
System.Runtime.CompilerServices
;
2
3
namespace
System
;
4
5
internal
static
class
HexConverter
6
{
7
public
enum
Casing
: uint
8
{
9
Upper
= 0u,
10
Lower
= 8224u
11
}
12
13
[MethodImpl(
MethodImplOptions
.AggressiveInlining)]
14
public
static
void
ToBytesBuffer
(
byte
value
,
Span<byte>
buffer
,
int
startingIndex = 0,
Casing
casing =
Casing
.Upper)
15
{
16
uint num = (uint)(((
value
& 0xF0) << 4) + (
value
& 0xF) - 35209);
17
uint num2 = ((((0 - num) & 0x7070) >> 4) + num + 47545) | (uint)casing;
18
buffer
[startingIndex + 1] = (byte)num2;
19
buffer
[startingIndex] = (byte)(num2 >> 8);
20
}
21
22
[MethodImpl(
MethodImplOptions
.AggressiveInlining)]
23
public
static
void
ToCharsBuffer
(
byte
value
,
Span<char>
buffer
,
int
startingIndex = 0,
Casing
casing =
Casing
.Upper)
24
{
25
uint num = (uint)(((
value
& 0xF0) << 4) + (
value
& 0xF) - 35209);
26
uint num2 = ((((0 - num) & 0x7070) >> 4) + num + 47545) | (uint)casing;
27
buffer
[startingIndex + 1] = (char)(num2 & 0xFFu);
28
buffer
[startingIndex] = (char)(num2 >> 8);
29
}
30
31
[MethodImpl(
MethodImplOptions
.AggressiveInlining)]
32
public
static
char
ToCharUpper
(
int
value
)
33
{
34
value
&= 0xF;
35
value
+= 48;
36
if
(
value
> 57)
37
{
38
value
+= 7;
39
}
40
return
(
char
)
value
;
41
}
42
}
System.HexConverter.ToCharsBuffer
static void ToCharsBuffer(byte value, Span< char > buffer, int startingIndex=0, Casing casing=Casing.Upper)
Definition
HexConverter.cs:23
System.HexConverter.Casing
Casing
Definition
HexConverter.cs:8
System.HexConverter.Casing.Upper
@ Upper
System.HexConverter.Casing.Lower
@ Lower
System.HexConverter.ToCharUpper
static char ToCharUpper(int value)
Definition
HexConverter.cs:32
System.HexConverter.ToBytesBuffer
static void ToBytesBuffer(byte value, Span< byte > buffer, int startingIndex=0, Casing casing=Casing.Upper)
Definition
HexConverter.cs:14
System.HexConverter
Definition
HexConverter.cs:6
System.Runtime.CompilerServices.MethodImplOptions
MethodImplOptions
Definition
MethodImplOptions.cs:5
System.Runtime.CompilerServices
Definition
NullablePublicOnlyAttribute.cs:3
System.ExceptionArgument.value
@ value
System.ExceptionArgument.buffer
@ buffer
System
Definition
BlockingCollection.cs:8
System.Span
Definition
Span.cs:14
source
System.Text.Encodings.Web
System
HexConverter.cs
Generated by
1.10.0