In NSString:-dataUsingEncoding:allowLossyConversion:, the variable
"count" is
used as a buffer byte counter for most formats (NSASCIIStringEncoding,
NSISOLatin1StringEncoding etc), and the malloced buffer is converted
to a
NSData object using "count" as the data count.
For NSUTF8StringEncoding however, "count" is not used as the counter --
"j"
is. But "count" is still used in line 2296 as the byte count sent to the
NSData object. This is always zero.
NSString:2296 was:
return [NSDataClass dataWithBytesNoCopy: buff
length: count];
and should be:
return [NSDataClass dataWithBytesNoCopy: buff
length: j];