UTF8.GetBytes type inference in mono
Posted: Wed Feb 20, 2008 9:20 pm
I've bumped into a bit of weirdness in mono with System.Text.Encoding.UTF8.
The following example behaves as expected under Microsoft's framework.
To get the same behavior under mono, I had to code it as:
The first bit of oddness is that under .NET, Cobra wants to use "uTF8", which is what it should be. However, under mono, Cobra wants "utF8".
The second thing is that Cobra is inferring a return type of Int32 for getBytes, which causes a C# compilation error unless it is explicitly cast to what it really is.
The following example behaves as expected under Microsoft's framework.
class Program
def main is shared
buf = System.Text.Encoding.uTF8.getBytes('yo')
for i in buf
print i
To get the same behavior under mono, I had to code it as:
class Program
def main is shared
buf = System.Text.Encoding.utF8.getBytes('yo') to Byte[]?
for i in buf
print i
The first bit of oddness is that under .NET, Cobra wants to use "uTF8", which is what it should be. However, under mono, Cobra wants "utF8".
The second thing is that Cobra is inferring a return type of Int32 for getBytes, which causes a C# compilation error unless it is explicitly cast to what it really is.