On Feb 2, 2009, at 7:50 PM, Joar Wingfors wrote:

How do you know what delimiter string to use? Another thing that you'd have to determine, guess or be told, right? In general I would guess that it in this case almost always would be impossible and / or inappropriate to attempt to determine either of these two, and that you would have to simply default to something reasonable.

UTF-8 covers most files, due to being backward-compatible with ASCII. Occasionally, ISO-8859-1 is a decent guess, due to its wide-spread usage (and is also compatible with ASCII).

But there's no general-purpose way to know for sure the character encoding if _all_ you have is a plain old text file. You always should provide a way for the user to specify character encoding, where it's not known for sure what the encoding is.

For line delimiters, it's almost always going to be \n or \r\n. It's simple enough to treat either as a line-break, or to ask the user if for some reason \n is a valid character within a line of a \r\n- delimited file (but that's very rare). Certainly, line-breaks are a lot easier to deal with in a general, reliable way than character encodings. :)

[...] In any case, if you think that Cocoa should provide an enumerator that given either NSData or a path / NSURL, and provided the appropriate encoding, returns individual lines as NSStrings, please make sure that you file a radar and ask for it.

I will indeed. It's unfortunate that the Radar system doesn't provide a way to view other people's submissions and to validate, vote, provide work-arounds for, or otherwise comment on them (รก la Microsoft's Connect web site). Making each person submit their own report is tedious, to say the least (thinking of Michael Ash's NSOperationQueue issue here :) ).

Pete_______________________________________________

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

Reply via email to