I have a Delphi 2007 DLL with this export:
function TestSignString(s, Sign: PChar): LongBool; stdcall;
I am calling it in .NET Core v7 C# using this import:
[DllImport(@"LibraryName.dll")]
[return:MarshalAs(UnmanagedType.Bool)]
internal static extern bool TestSignString(string s, string sign);
I am passing s
and sign
params, when the run-time system has default encoding (EXPECTED) WIN1250 everything goes fine as expected, however when it's not, there's default system encoding involved and passed chars are encoded using default encoding (for example to WIN1252).
So my question is, how to override default encoding when marshaling strings in C#? I mean both ways - as a input params and output as well, please.
I have tried altering the import to:
[DllImport(@"LockBoxLibrary.dll", CharSet = CharSet.Ansi)]
but no luck, I am missing code page (1250) specification.