Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ StringToAnsiString()

static unsafe int System.Runtime.InteropServices.Marshal.StringToAnsiString ( string s,
byte * buffer,
int bufferLength,
bool bestFit = false,
bool throwOnUnmappableChar = false )
inlinestaticpackage

Definition at line 1608 of file Marshal.cs.

1609 {
1610 uint dwFlags = ((!bestFit) ? 1024u : 0u);
1611 uint num = 0u;
1612 int num2;
1613 fixed (char* lpWideCharStr = s)
1614 {
1615 num2 = Interop.Kernel32.WideCharToMultiByte(0u, dwFlags, lpWideCharStr, s.Length, buffer, bufferLength, IntPtr.Zero, throwOnUnmappableChar ? new IntPtr(&num) : IntPtr.Zero);
1616 }
1617 if (num != 0)
1618 {
1619 throw new ArgumentException(SR.Interop_Marshal_Unmappable_Char);
1620 }
1621 buffer[num2] = 0;
1622 return num2;
1623 }
static unsafe int WideCharToMultiByte(uint CodePage, uint dwFlags, char *lpWideCharStr, int cchWideChar, byte *lpMultiByteStr, int cbMultiByte, IntPtr lpDefaultChar, IntPtr lpUsedDefaultChar)

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

Referenced by System.StubHelpers.AsAnyMarshaler.ConvertStringBuilderToNative(), System.StubHelpers.AnsiCharMarshaler.ConvertToNative(), System.StubHelpers.CSTRMarshaler.ConvertToNative(), System.StubHelpers.AnsiCharMarshaler.DoAnsiConversion(), System.Runtime.InteropServices.Marshal.StringToCoTaskMemAnsi(), and System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi().