Thanks, but I have not tried. My thinking went along the lines of if I read the string directly from the URL I have no control over what encoding is being used for reading or it defaults to something. If I first read as data, I can do with those bytes as I please. The DBF file is not in one consistent encoding from start to finish. The DBF file format documentation says the header is in binary, then there is a linefeed (\r), then there is the body. Each field has a fixed length, wether used or not doesn't matter, the unused rest is filled with spaces.
So, I read the file as data, stringily it as DOSLatin1, split it at the linefeed and read the body according to the field definitions I am given. They are guaranteed, so maybe some day I get around to writing a nice DBF parser, but until then I go by the guaranteed field lengths. I tested it now on a couple of files and it works without a hitch. Am 22.12.2011 um 14:40 schrieb Mike Abdullah: > > On 22 Dec 2011, at 09:59, Alexander Reichstadt wrote: > >> Thanks, it works. The following solved the problem, where theChoice is a URL >> to a local file from an NSOpenPanel: >> >> NSData *theData = [NSData dataWithContentsOfURL:theChoice]; >> NSString *theContent = [[NSString alloc] initWithData:theData encoding: >> >> CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingDOSLatin1) >> ]; > > You can initialise a string directly from the contents of a URL you realise, > right? Or are you saying that doesn't work, but this technique somehow does? > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com