News for hackers. Stuff that matters.

Ask HN: What justify this 149bytes difference? [text editor related]

http://cl.ly/3P302w3e3A2p3D261U0H/o

Assuming: - a single char takes 1 byte. - a linked list takes about 5 bytes/char. - a double linked list takes about 9 bytes/char.

1. Why is "Plain Text" format so low on memory. Is it using an array as storage?

2. Why is "Rich Format" so heavy?

Insight, details answers, and links welcome.

( 4 comments | on HN )
Re:Ask HN: What justify this 149bytes difference? [text edit... by read_wharf on Sunday April 15, 2012 @12:40PM (#3844017)
https://en.wikipedia.org/wiki/Rich_Text_Format#Code_example

From their example:

    $ echo "{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard
    This is some {\b bold} text.\par
    }" |wc -c
    86
    
    $ echo "This is some bold text." |wc -c
    24
Also see cd34's comment.

If you're going to add information, that has to be a higher byte count.

Re:Ask HN: What justify this 149bytes difference? [text edit... by aolczak on Sunday April 15, 2012 @01:05PM (#3844090)
forgot the default font, size, alignment and so on, on rtf.

thanks for pointing that out.

Re:Ask HN: What justify this 149bytes difference? [text edit... by cd34 on Sunday April 15, 2012 @12:22PM (#3843978)
Move the file to a linux/bsd machine and do:

  hexdump -C plaintextfilename
  hexdump -C richtextfilename
Re:Ask HN: What justify this 149bytes difference? [text edit... by aolczak on Sunday April 15, 2012 @01:01PM (#3844082)
thanks for this Canonical hex+ASCII display tip.

can't try atm, but will as soon as I can log to linux.