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 static ReadOnlySpan<byte> CharToHexLookup => new byte[256]
8 {
9 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
10 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
11 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
12 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
13 255, 255, 255, 255, 255, 255, 255, 255, 0, 1,
14 2, 3, 4, 5, 6, 7, 8, 9, 255, 255,
15 255, 255, 255, 255, 255, 10, 11, 12, 13, 14,
16 15, 255, 255, 255, 255, 255, 255, 255, 255, 255,
17 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
18 255, 255, 255, 255, 255, 255, 255, 10, 11, 12,
19 13, 14, 15, 255, 255, 255, 255, 255, 255, 255,
20 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
21 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
22 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
23 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
24 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
25 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
26 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
27 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
28 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
29 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
30 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
31 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
32 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
33 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
34 255, 255, 255, 255, 255, 255
35 };
36
37 [MethodImpl(MethodImplOptions.AggressiveInlining)]
38 public static char ToCharLower(int value)
39 {
40 value &= 0xF;
41 value += 48;
42 if (value > 57)
43 {
44 value += 39;
45 }
46 return (char)value;
47 }
48
49 [MethodImpl(MethodImplOptions.AggressiveInlining)]
50 public static int FromChar(int c)
51 {
52 if (c < CharToHexLookup.Length)
53 {
54 return CharToHexLookup[c];
55 }
56 return 255;
57 }
58}
static char ToCharLower(int value)
static ReadOnlySpan< byte > CharToHexLookup
static int FromChar(int c)