"Cue Sheet Parser" - Use NSString?

  • Hi everyone!

    I'm very new to Cocoa and Objective-C development, so forgive me If I
    ask simple question... ;)

    I have a project to develop a cue/flac reader. My first move for that
    project is to create a cue parser. Is the NSString
    class is appropriate, by using this:

    - (id)initWithContentsOfFile:(NSString *)path encoding:
    (NSStringEncoding)enc error:(NSError **)error

    ?

    Cue Sheet are very shor text file, and I just need to read it to parse
    it.

    Thanks !

    Benjamin

    ------------------------
    Benjamin Frere
    www.iabloko.com
    ------------------------
  • Am 20.11.2007 um 22:45 schrieb Benjamin Frere:
    > - (id)initWithContentsOfFile:(NSString *)path encoding:
    > (NSStringEncoding)enc error:(NSError **)error
    >
    > ?
    >
    > Cue Sheet are very shor text file, and I just need to read it to
    > parse it.

      If they really are *text*, then yes. We've had some people here a
    while ago trying to use NSString to read binary files, and they
    weren't happy...

      Just make sure you choose the right encoding. In 99% of the cases,
    ASCII is the wrong encoding, because there is no such thing as Mac-
    ASCII or Windows-ASCII... You may also want to have a look at the
    NSScanner class, which is kinda helpful for parsing text of all kinds.

    Cheers,
    -- M. Uli Kusterer
    "The Witnesses of TeachText are everywhere..."
    http://www.zathras.de
  • Thanks!
    Hopefully, there are real text files. Here's an example:

    PERFORMER "Keith Jarrett"
    TITLE "The Köln Concert"
    FILE "Keith Jarrett - The Köln Concert.flac" WAVE
      TRACK 01 AUDIO
        TITLE "Köln, January 24, 1975 Part I"
        INDEX 00 00:00:00
        INDEX 01 00:00:33
      TRACK 02 AUDIO
        TITLE "Köln, January 24, 1975 Part II a"
        ISRC 0P4000700260
        INDEX 01 26:02:03
      TRACK 03 AUDIO
        TITLE "Köln, January 24, 1975 Part II b"
        INDEX 01 40:56:58
      TRACK 04 AUDIO
        TITLE "Köln, January 24, 1975 Part II c"
        INDEX 01 59:11:20

    For the encoding, it's 99% of the time in Windows Latin-1, as they
    comes from the Windows World.
    But I would provide to the user a preference in the encoding (for the
    reading).

    I didn't know about the NSScanner class ! Thanks a lot about it. I
    suppose that will make my life easier :)

    Benjamin

    ------------------------
    Benjamin Frere
    www.iabloko.com
    ------------------------

    On 21 Nov 2007, at 00:32, Uli Kusterer wrote:

    > Am 20.11.2007 um 22:45 schrieb Benjamin Frere:
    >> - (id)initWithContentsOfFile:(NSString *)path encoding:
    >> (NSStringEncoding)enc error:(NSError **)error
    >>
    >> ?
    >>
    >> Cue Sheet are very shor text file, and I just need to read it to
    >> parse it.
    >
    >
    > If they really are *text*, then yes. We've had some people here a
    > while ago trying to use NSString to read binary files, and they
    > weren't happy...
    >
    > Just make sure you choose the right encoding. In 99% of the cases,
    > ASCII is the wrong encoding, because there is no such thing as Mac-
    > ASCII or Windows-ASCII... You may also want to have a look at the
    > NSScanner class, which is kinda helpful for parsing text of all kinds.
    >
    > Cheers,
    > -- M. Uli Kusterer
    > "The Witnesses of TeachText are everywhere..."
    > http://www.zathras.de
    >
    >
    >
    >
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today