Matt's Mind

Wednesday, September 08, 2004

More API craziness

This is how you make a String from an array of bytes in .NET:
System.Text.Encoding encoding = System.Text.Encoding.UTF8;

return encoding.GetString (buffer);
This is how you do it in Java:
return new String (buffer, "UTF-8");
If you have an array of bytes that you want to stringify, then you'll likely go straight to the String class to see what kinds of things it can do with byte arrays. In .NET you need to find your way to System.Text.Encoding and then work it out from there.

(I really, really dislike .NET's "always capitalise everything whether it's a package, class, constant or variable" naming convention. What a waste of an alphabet).

0 Comments:

Post a Comment

<< Home