Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ LoadManagedCodePage()

unsafe override void System.Text.SBCSCodePageEncoding.LoadManagedCodePage ( )
inlineprotected

Definition at line 54 of file SBCSCodePageEncoding.cs.

55 {
56 fixed (byte* ptr = &m_codePageHeader[0])
57 {
58 CodePageHeader* ptr2 = (CodePageHeader*)ptr;
59 if (ptr2->ByteCount != 1)
60 {
61 throw new NotSupportedException(System.SR.Format(System.SR.NotSupported_NoCodepageData, CodePage));
62 }
63 _byteUnknown = (byte)ptr2->ByteReplace;
64 _charUnknown = ptr2->UnicodeReplace;
65 int num = 66052 + iExtraBytes;
66 byte* nativeMemory = GetNativeMemory(num);
67 Unsafe.InitBlockUnaligned(nativeMemory, 0, (uint)num);
68 char* ptr3 = (char*)nativeMemory;
69 byte* ptr4 = nativeMemory + 512;
70 byte[] array = new byte[512];
71 lock (BaseCodePageEncoding.s_streamLock)
72 {
73 BaseCodePageEncoding.s_codePagesEncodingDataStream.Seek(m_firstDataWordOffset, SeekOrigin.Begin);
74 BaseCodePageEncoding.s_codePagesEncodingDataStream.Read(array, 0, array.Length);
75 }
76 fixed (byte* ptr5 = &array[0])
77 {
78 for (int i = 0; i < 256; i++)
79 {
80 char c = (char)ReadUInt16(ptr5 + 2 * i);
81 if (c != 0 || i == 0)
82 {
83 ptr3[i] = c;
84 if (c != '\ufffd')
85 {
86 ptr4[(int)c] = (byte)i;
87 }
88 }
89 else
90 {
91 ptr3[i] = '\ufffd';
92 }
93 }
94 }
95 _mapBytesToUnicode = ptr3;
96 _mapUnicodeToBytes = ptr4;
97 }
98 }
static unsafe void InitBlockUnaligned(void *startAddress, byte value, uint byteCount)
Definition Unsafe.cs:133
static string NotSupported_NoCodepageData
Definition SR.cs:1688
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7
BaseCodePageEncoding(int codepage, int dataCodePage)
unsafe byte * GetNativeMemory(int iSize)
virtual int CodePage
Definition Encoding.cs:515
static unsafe ushort ReadUInt16(byte *pByte)

References System.Text.SBCSCodePageEncoding._byteUnknown, System.Text.SBCSCodePageEncoding._charUnknown, System.Text.SBCSCodePageEncoding._mapBytesToUnicode, System.Text.SBCSCodePageEncoding._mapUnicodeToBytes, System.array, System.Text.BaseCodePageEncoding.CodePageHeader.ByteCount, System.Text.BaseCodePageEncoding.CodePageHeader.ByteReplace, System.Text.Encoding.CodePage, System.SR.Format(), System.Text.BaseCodePageEncoding.GetNativeMemory(), System.Text.BaseCodePageEncoding.iExtraBytes, System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(), System.Text.BaseCodePageEncoding.m_codePageHeader, System.Text.BaseCodePageEncoding.m_firstDataWordOffset, System.SR.NotSupported_NoCodepageData, System.Text.SBCSCodePageEncoding.ReadUInt16(), System.Text.BaseCodePageEncoding.s_codePagesEncodingDataStream, System.Text.BaseCodePageEncoding.s_streamLock, and System.Text.BaseCodePageEncoding.CodePageHeader.UnicodeReplace.