re: any way to determine the encoding type of an NSData object?
re: any way to determine the encoding type of an NSData object?
- Subject: re: any way to determine the encoding type of an NSData object?
- From: Francisco Tolmasky <email@hidden>
- Date: Sun, 4 Jan 2004 05:05:50 -0800
Use:
NSMutableAttributedString's
- (BOOL)readFromURL:(NSURL *)url options:(NSDictionary *)options
documentAttributes:(NSDictionary**)documentAttributes
BOOL success;
NSDictionary *docAttrs;
NSURL *url = [NSURL fileURLWithPath: fileName];
NSMutableDictionary *options= [NSMutableDictionary dictionary];
NSTextStorage *myTextStorage;
success= [text readFromURL: url options: options documentAttributes:
&docAttrs];
[docAttrs objectForKey: @"DocumentType"]; // The MONEY!
I learned this from the source code for TextEdit. It's located
Developer/Examples/AppKit/TextEdit/
This whole encoding nonsense is handled in DocumentReadWrite.m
It's kind of construed when you do this, you need to bypass the normal
file opening behavior to get it to call it with the filename. You'll
see what I'm talking about in controller.m
Francisco Tolmasky
email@hidden
http://users.adelphia.net/~ftolmasky
_______________________________________________
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.