Data to String: what encoding?
Data to String: what encoding?
- Subject: Data to String: what encoding?
- From: Randall Crenshaw <email@hidden>
- Date: Sun, 15 Sep 2002 12:24:20 -0700 (PDT)
Hi,
I am wanting to convert an NSData to NSString. The data
came from a file. I have no idea what it's encoding is -
could be anything AFAIK.
NSData *d = [NSData dataWithContentsOfFile:filename];
// do something that requires an NSData object
// if it doesn't work, well, then it needs to be a String
NSString *s = [[NSString alloc] initWithData:d
encoding:XXXXXX];
There doesn't seem to be a method like -(NSStringEncoding)
stringEncoding; on NSData. How does one deal with
arbitrary encodings? My method should be able to open any
file that can be saved on the disk. I really don't want to
worry about encodings, but if I have to then I need a way
to discover them dynamically.
I do not want to re-read the file from disk using
stringWithContentsOfFile:. Can encoding: be nil in
initWith
Data:encoding:?
It's possible that I'm going about this backwards. Maybe I
should just read the string first and then convert it to
NSData which doesn't require knowledge of encodings...
Thanks!
Randy
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com
_______________________________________________
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.