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

◆ ConvertFixedToNative()

static unsafe void System.StubHelpers.CSTRMarshaler.ConvertFixedToNative ( int flags,
string strManaged,
IntPtr pNativeBuffer,
int length )
inlinestaticpackage

Definition at line 64 of file CSTRMarshaler.cs.

65 {
66 if (strManaged == null)
67 {
68 if (length > 0)
69 {
70 *(sbyte*)(void*)pNativeBuffer = 0;
71 }
72 return;
73 }
74 int num = strManaged.Length;
75 if (num >= length)
76 {
77 num = length - 1;
78 }
79 byte* ptr = (byte*)(void*)pNativeBuffer;
80 bool flag = flags >> 8 != 0;
81 bool flag2 = (flags & 0xFF) != 0;
82 uint num2 = 0u;
83 int num3;
84 fixed (char* lpWideCharStr = strManaged)
85 {
86 num3 = Interop.Kernel32.WideCharToMultiByte(0u, (!flag2) ? 1024u : 0u, lpWideCharStr, num, ptr, length, IntPtr.Zero, flag ? new IntPtr(&num2) : IntPtr.Zero);
87 }
88 if (num2 != 0)
89 {
90 throw new ArgumentException(SR.Interop_Marshal_Unmappable_Char);
91 }
92 if (num3 == length)
93 {
94 num3--;
95 }
96 ptr[num3] = 0;
97 }
static unsafe int WideCharToMultiByte(uint CodePage, uint dwFlags, char *lpWideCharStr, int cchWideChar, byte *lpMultiByteStr, int cbMultiByte, IntPtr lpDefaultChar, IntPtr lpUsedDefaultChar)

References System.SR.Interop_Marshal_Unmappable_Char, System.length, Interop.Kernel32.WideCharToMultiByte(), and System.IntPtr.Zero.