• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Checking for line ending types
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking for line ending types


  • Subject: Re: Checking for line ending types
  • From: Craig Hunter <email@hidden>
  • Date: Sun, 28 Nov 2004 23:29:35 -0500

>
> Message: 15
> Date: Sun, 28 Nov 2004 18:22:52 -0800 (PST)
> From: Mike S <email@hidden>
> Subject: Re: Checking for line ending types
> To: email@hidden
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=us-ascii
>
> I'm running into a similar problem  using
> NSString * contents = [NSString
> stringWithContentsOfFile:newPath];
> NSArray * contentsArray = [contents
> componentsSeparatedByString:@"\n"];
>
> with a file that is a concatenation of pieces of files
> from a noaa FTP site.  Files were downloaded to a
> windows machine then copied to a mac, then pieces
> pulled out and concatenated using Appleworks  and
> saving the resulting file as a text file from
> Appleworks.
>
> the NSString method reads the file in fine and can
> print it back out verbatim, however the resulting
> NSArray has only a single entry that is the entire
> file, rather than the 100+ entries I expected for the
> 100+ lines in the file.   Should I be looking for a
> "\r" as an end of line character?
> mike stoughton


Sounds like you have Mac line endings which are just carriage returns (\r).
DOS line endings would have both carriage returns and newlines (\r\n) while
UNIX line endings are just newlines (\n).  Since you are going through a
pretty convoluted process to assemble the files, I think you should probably
streamline the pre-processing and standardize on a line ending convention
first and foremost!

And of course, you can use utilities like BBEdit to change the line endings,
or simple shell commands:

    dos2unix:  tr -d \\r < dosfile > unixfile

    mac2unix:  tr \\r \\n < macfile > unixfile

and so on....

Craig

--
Dr. Craig A. Hunter
NASA Langley Research Center
AAAC / Configuration Aerodynamics Branch
(757) 864-3020
email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: binding a TableView with non-CF collection data?
  • Next by Date: Re: binding a TableView with non-CF collection data?
  • Previous by thread: Re: Checking for line ending types
  • Next by thread: checking for line ending types
  • Index(es):
    • Date
    • Thread