Thread: Newline parsing?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    67

    Newline parsing?

    I'm creating an XML parser (please don't suggest any. The point is, I'm making it myself), and I realized that while using fseek, you scrawl through the exact bytes of a file, but when you fread, 0x0A0D (newline character.. for some reason it's 2 bytes long) gets parsed to 0x0A.. it's very annoying, because the file MIGHT have just had 0x0A (not 0x0A0D) so I can't just add 1 to what I'm fseeking if I encounter a 0x0A in my parsed data, but I can't ignore it because that throws it off. Is there any way around this newline parsing problem?
    got the solution. Open it as a binary file (the default is text). Add a 'b' to the end of your opening mode (e.g. "r" becomes "rb"). You don't need to change anything else
    Last edited by RobotGymnast; 07-11-2008 at 10:31 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. draw tree graph of yacc parsing
    By talz13 in forum C Programming
    Replies: 2
    Last Post: 07-23-2006, 01:33 AM
  2. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  3. Parsing for Dummies
    By MisterWonderful in forum C++ Programming
    Replies: 4
    Last Post: 03-08-2004, 05:31 PM
  4. I hate string parsing with a passion
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 03-19-2002, 07:30 PM
  5. fgets and a bothersome newline char
    By ivandn in forum Linux Programming
    Replies: 1
    Last Post: 11-14-2001, 01:41 PM