Re: PB Save As ASCII?
Re: PB Save As ASCII?
- Subject: Re: PB Save As ASCII?
- From: Ondra Cada <email@hidden>
- Date: Thu, 14 Feb 2002 21:46:43 +0100
Todd,
>
>>>>> Todd Blanchard (TB) wrote at Thu, 14 Feb 2002 09:22:12 -0800:
TB> This sucks. I'm going to have to retype the whole 2 pages of code by
TB> hand because no utility I can find will save the text as lossy ascii.
Although I completely share your sentiment of things which are so foolproof
to be actually next to unuseable, I guess you could do this in *considerably*
shorter time:
24 /tmp> cat > q.m
#import <Foundation/Foundation.h>
void main() {
id p=[NSAutoreleasePool new];
id d=[NSData dataWithContentsOfFile:@"contacts.vcf"];
id s=[[NSString alloc] initWithData:d encoding:NSUTF8StringEncoding];
d=[s dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
[d writeToFile:@"/tmp/contacts.vcf" atomically:NO];
}
25 /tmp> cc -framework Foundation q.m && ./a.out
q.m: In function `main':
q.m:2: warning: return type of `main' is not `int'
26 /tmp>
using, of course, the name of your offending file and appropriate encoding
instead of mine "contacts.vcf" and NSUTF8StringEncoding which I used so as
the test did anything for real...
And naturally, if your file is saveable into any one-byte encoding (say, ISO
L2), you can use much simpler "tr -d '\200-\377' < infile > outfile" in a
fraction of even those few minutes needed for the above ;))))
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.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.