char in C# is not the same thing as char in C++
dmedine opened this issue · comments
David Medine commented
This is just a heads up as I ran into this problem in a different project.
Without testing it, I can say for sure that this:
Line 572 in c74a4d4
char[] sample
variable on the C# side will always contain 0s. The reason is that in C# a char
is not a primitive type, but rather an object that can be either 1 or 2 bytes depending on how it is encoded. Thus, this pointer won't marshal properly from managed to unmanaged code and the contents will simply retain their default initialization values.
The correct way to do this is to use byte[]
on the C# side and then convert it to a char array like so:
char[] sample = System.Text.Encoding.ASCII.GetString(byte_sample).ToCharrArray()'
The same issue will occur with pull_chunk(char[,]...)
I don't know if this really matters. I can't see why anyone would need this overload in the C# wrapper. The overload with string
works just fine.