1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 using System.Diagnostics;
8 namespace System.Runtime.InteropServices
10 public static partial class Marshal
12 private static int GetSystemMaxDBCSCharSize() => 3;
14 private static bool IsWin32Atom(IntPtr ptr) => false;
16 internal static unsafe int StringToAnsiString(string s, byte* buffer, int bufferLength, bool bestFit = false, bool throwOnUnmappableChar = false)
18 Debug.Assert(bufferLength >= (s.Length + 1) * SystemMaxDBCSCharSize, "Insufficient buffer length passed to StringToAnsiString");
22 fixed (char* pChar = s)
24 convertedBytes = Encoding.UTF8.GetBytes(pChar, s.Length, buffer, bufferLength);
27 buffer[convertedBytes] = 0;
29 return convertedBytes;