In .NET, I can use Encoding.UTF8.GetString(string str)
or any other flavor of Encoding
, to get the string representation of a byte array. Does Cocoa contain similar functionality out-of-the-box, or do I need to write some stuff to make the conversions myself?
views:
35answers:
1
+7
A:
You use initWithData:encoding
. E.g.:
[[NSString alloc] initWithData: dataObj encoding: NSUTF8StringEncoding]
Matthew Flaschen
2010-07-23 02:39:12
Thanks--very simple, very elegant!
Brian Warshaw
2010-07-23 03:31:49