File tree Expand file tree Collapse file tree 1 file changed +0
-45
lines changed Expand file tree Collapse file tree 1 file changed +0
-45
lines changed Original file line number Diff line number Diff line change @@ -189,49 +189,4 @@ public static ICustomMarshaler GetInstance(string cookie)
189
189
return Instance ;
190
190
}
191
191
}
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
- }
237
192
}
You can’t perform that action at this time.
0 commit comments