Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 60bb68c

Browse files
committed
removed unused Utf8Marshaler
1 parent c3fc7f0 commit 60bb68c

File tree

1 file changed

+0
-45
lines changed

1 file changed

+0
-45
lines changed

src/runtime/CustomMarshaler.cs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -189,49 +189,4 @@ public static ICustomMarshaler GetInstance(string cookie)
189189
return Instance;
190190
}
191191
}
192-
193-
194-
/// <summary>
195-
/// Custom Marshaler to deal with Managed String to Native
196-
/// conversion on UTF-8. Use on functions that expect UTF-8 encoded
197-
/// strings like `PyUnicode_FromStringAndSize`
198-
/// </summary>
199-
/// <remarks>
200-
/// If instead we used `MarshalAs(UnmanagedType.LPWStr)` the output to
201-
/// `foo` would be `f\x00o\x00o\x00`.
202-
/// </remarks>
203-
internal class Utf8Marshaler : MarshalerBase
204-
{
205-
private static readonly MarshalerBase Instance = new Utf8Marshaler();
206-
private static readonly Encoding PyEncoding = Encoding.UTF8;
207-
208-
public override IntPtr MarshalManagedToNative(object managedObj)
209-
{
210-
var s = managedObj as string;
211-
212-
if (s == null)
213-
{
214-
return IntPtr.Zero;
215-
}
216-
217-
byte[] bStr = PyEncoding.GetBytes(s + "\0");
218-
IntPtr mem = Marshal.AllocHGlobal(bStr.Length);
219-
try
220-
{
221-
Marshal.Copy(bStr, 0, mem, bStr.Length);
222-
}
223-
catch (Exception)
224-
{
225-
Marshal.FreeHGlobal(mem);
226-
throw;
227-
}
228-
229-
return mem;
230-
}
231-
232-
public static ICustomMarshaler GetInstance(string cookie)
233-
{
234-
return Instance;
235-
}
236-
}
237192
}

0 commit comments

Comments
 (0)