Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
EncodingHelper.cs
Go to the documentation of this file.
4
6
7internal static class EncodingHelper
8{
9 internal static bool TestOnly_LightUpEnabled
10 {
11 get
12 {
13 return true;
14 }
15 set
16 {
17 }
18 }
19
20 public unsafe static string DecodeUtf8(byte* bytes, int byteCount, byte[]? prefix, MetadataStringDecoder utf8Decoder)
21 {
22 if (prefix != null)
23 {
24 return DecodeUtf8Prefixed(bytes, byteCount, prefix, utf8Decoder);
25 }
26 if (byteCount == 0)
27 {
28 return string.Empty;
29 }
30 return utf8Decoder.GetString(bytes, byteCount);
31 }
32
33 private unsafe static string DecodeUtf8Prefixed(byte* bytes, int byteCount, byte[] prefix, MetadataStringDecoder utf8Decoder)
34 {
35 int num = byteCount + prefix.Length;
36 if (num == 0)
37 {
38 return string.Empty;
39 }
40 byte[] array = ArrayPool<byte>.Shared.Rent(num);
41 prefix.CopyTo(array, 0);
43 string @string;
44 fixed (byte* bytes2 = &array[0])
45 {
46 @string = utf8Decoder.GetString(bytes2, num);
47 }
49 return @string;
50 }
51}
static ArrayPool< T > Shared
Definition ArrayPool.cs:7
static unsafe string DecodeUtf8(byte *bytes, int byteCount, byte[]? prefix, MetadataStringDecoder utf8Decoder)
static unsafe string DecodeUtf8Prefixed(byte *bytes, int byteCount, byte[] prefix, MetadataStringDecoder utf8Decoder)
virtual unsafe string GetString(byte *bytes, int byteCount)
static void Copy(int[] source, int startIndex, IntPtr destination, int length)
Definition Marshal.cs:800