0

I have a legacy Delphi COM library that accepts an ANSI string (code page 1252) as parameter.
The generated .net wrapper accepts a string for this parameter. Passing in a regular string however doesn't end well. If passed in the '°' character a question mark takes up it's spot.

How can I go and debug this? Is it the com wrapper not recognising the correct encoding? How can I pass in an ANSI string (I can convert it to bytes, but the API requires a string, so it is converted to UTF16 again)

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
Boris Callens
  • 90,659
  • 85
  • 207
  • 305
  • On your computer, what is the setting for "Language for Non Unicode Programs"? – NineBerry Apr 01 '23 at 17:22
  • Can you name the Delphi COM library? Is it publicly available? – NineBerry Apr 01 '23 at 17:23
  • What happens when you output the string from c# (Via MessageBox for example)? Where do you see the text in your delphi library? In the console, in some file or UI? – NineBerry Apr 01 '23 at 17:27
  • I'm sorry Nineberry. This question is from 2009 :D I no longer work at my first company but I vaguely remember it was a matter of the right configuration when creating the component in Delphi. – Boris Callens Apr 22 '23 at 19:20

1 Answers1

0

One workaround would be to write an intermediate layer in an unmanaged language that would redirect calls to the original library and use MultiByteToWideChar for conversion. That's quite easy and a good solution if you don't convince the wrapper some other way.

sharptooth
  • 167,383
  • 100
  • 513
  • 979