Re: NSStringEncoding troubles
Re: NSStringEncoding troubles
- Subject: Re: NSStringEncoding troubles
- From: Ondra Cada <email@hidden>
- Date: Sun, 14 Jul 2002 12:52:01 +0200
On Sunday, July 14, 2002, at 12:21 , Adrian Rutledge wrote:
...while [[NSString alloc] initWithData:bleh
encoding:NSSomeStringEncoding] works, it escapes non-printing values such
as ASCII 02...
So far as I can say, it does not. I guess you just falled to the
"NSLog-tries-to-be-clever-when-showing-nonprintables" trap as many others
did before. Just check for yourself, like with
65 /tmp> cat q.m
#import <Foundation/Foundation.h>
int main() {
id p=[NSAutoreleasePool new];
id d=[[NSData alloc] initWithBytes:"(\2)" length:3];
id s=[[NSString alloc] initWithData:d encoding:NSISOLatin2StringEncoding];
int l=[s length],i;
NSLog(@"len %d",l);
for (i=0;i<l;i++) NSLog(@"char at %d is %d",i,[s characterAtIndex:i]);
return 0;
}
66 /tmp> cc -framework Foundation q.m && ./a.out
2002-07-14 12:51:25.136 a.out[5714] len 3
2002-07-14 12:51:25.138 a.out[5714] char at 0 is 40
2002-07-14 12:51:25.138 a.out[5714] char at 1 is 2
2002-07-14 12:51:25.138 a.out[5714] char at 2 is 41
67 /tmp>
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.