“NSString stringWithUTF8String:” is overly touchy
问题 I'm in the middle of doing some string manipulation using high-level Cocoa features like NSString and NSData as opposed to digging down to C-level things like working on arrays of char s. For the love of it, +[NSString stringWithUTF8String:] sometimes returns nil on a perfectly good string that was created with -[NSString UTF8String] in the first place. One would assume that this happens when the input is malformed. Here is an example of the input that fails, in hex: 55 6B 66 51 35 59 4A 5C