[Mono-dev] String comparison failing between C# and C
dkosawa at gmail.com
Thu Nov 15 16:18:16 EST 2007
I'm currently testing Mono's interoperability between C# and C code, and
have run into an interesting scenario.
In my test case I have a C shared object that implements two functions:
setString and getString. The first function, setString, simply copies the
string into a local buffer. The second function, getString, returns a
pointer to the internal buffer holding the string.
What's interesting is that the first case (in the below C# code) fails when
it tries to compare "hello" against the return value of getString. Is this
a problem with trying to compare a unicode string with an ansi string? This
test case passes when running under Windows via CLR...fails in Linux via
The second case, "hello" == s, passes.
public class Tester : ITester
static extern void setString(string s);
static extern string getString();
string s = getString();
if ("hello" == getString())
Console.WriteLine("hello == getString passed!");
Console.WriteLine("hello == getString failed!");
if (("hello" == s)
Console.WriteLine("hello == s passed!");
Console.WriteLine("hello == s failed!");
I'm running this on an embedded PPC Arabella Linux system, using mono
Thanks in Advance,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-devel-list