Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HexConverter.cs
Go to the documentation of this file.
2
3namespace System;
4
5internal 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}
static void ToCharsBuffer(byte value, Span< char > buffer, int startingIndex=0, Casing casing=Casing.Upper)
static char ToCharUpper(int value)
static void ToBytesBuffer(byte value, Span< byte > buffer, int startingIndex=0, Casing casing=Casing.Upper)