Skip to content

Instantly share code, notes, and snippets.

@sonsongithub
Created September 7, 2014 21:34
Show Gist options
  • Save sonsongithub/139bcd5b2f66f1ccdf7a to your computer and use it in GitHub Desktop.
Save sonsongithub/139bcd5b2f66f1ccdf7a to your computer and use it in GitHub Desktop.
check inside of NSString
void hoge(NSString* temp) {
DNSLog(@"------------------%ld", temp.length);
NSData *data = [temp dataUsingEncoding:NSUTF8StringEncoding];
unichar *uni = nil;
uni = (unichar*)malloc(sizeof(unichar) * temp.length);
[temp getCharacters:uni];
for (int i = 0; i < [temp length]; i++) {
NSLog(@"%d - %04x", i, *(uni + i ));
}
DNSLog(@"%@", data);
DNSLog(@"%ld", [data length]);
char *p = (char*)[data bytes];
for (int i = 0; i < [data length]; i++) {
NSLog(@"%02x", *(p + i ));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment