Skip to content

Instantly share code, notes, and snippets.

@uliwitness
Created August 28, 2015 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uliwitness/e86d35804ec3815c6e74 to your computer and use it in GitHub Desktop.
Save uliwitness/e86d35804ec3815c6e74 to your computer and use it in GitHub Desktop.
Test program that shows that NSString can do '\0' characters, however NSLog will terminate its entire output at encountering the first one:
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
NSString *str = [[NSString alloc] initWithBytes: "\0\r" length: 2 encoding: NSASCIIStringEncoding];
NSLog(@"len = %zu \"%@\"", str.length, str);
}
}
2015-08-28 16:48:07.729 Untitled[4116:2242682] len = 2 "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment