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

◆ GetAnsiStringBytes()

static unsafe void System.Runtime.InteropServices.Marshal.GetAnsiStringBytes ( ReadOnlySpan< char > chars,
Span< byte > bytes )
inlinestaticpackage

Definition at line 1646 of file Marshal.cs.

1647 {
1648 int num;
1649 if (chars.Length == 0)
1650 {
1651 num = 0;
1652 }
1653 else
1654 {
1655 fixed (char* lpWideCharStr = chars)
1656 {
1657 fixed (byte* lpMultiByteStr = bytes)
1658 {
1659 num = Interop.Kernel32.WideCharToMultiByte(0u, 1024u, lpWideCharStr, chars.Length, lpMultiByteStr, bytes.Length, IntPtr.Zero, IntPtr.Zero);
1660 if (num <= 0)
1661 {
1662 throw new ArgumentException();
1663 }
1664 }
1665 }
1666 }
1667 bytes[num] = 0;
1668 }
static unsafe int WideCharToMultiByte(uint CodePage, uint dwFlags, char *lpWideCharStr, int cchWideChar, byte *lpMultiByteStr, int cbMultiByte, IntPtr lpDefaultChar, IntPtr lpUsedDefaultChar)

References System.bytes, System.chars, Interop.Kernel32.WideCharToMultiByte(), and System.IntPtr.Zero.

Referenced by System.Security.SecureString.MarshalToString().