[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: suggestion: function: buffer-bytes

From: T. V. Raman
Subject: Re: suggestion: function: buffer-bytes
Date: Sat, 30 Jun 2007 19:40:07 -0700


Where I used this:

Package g-client 

I use curl to talk HTTP in that package -- uses Atom Publishing
Protocol to talk to servers --
and I needed the byte count  for computing HTTP headers
It does appear to work, but also because I do set buffer-encoding
appropriately in those buffers where I am building up the HTTP
message being posted.
buffer-size definitely bombs in that use case -- do you have a
better suggestion for how one might count bytes?

>>>>> "Stefan" == Stefan Monnier <address@hidden> writes:
    >> Emacs built-in buffer-size returns the number of
    >> characters --- in some situations one needs the count of
    >> bytes.  Here is a small function that does this ---
    >> perhaps it could be ncluded in subr.el?
    >> (defsubst buffer-bytes (&optional buffer) "Return number
    >> of bytes in a buffer."  (save-excursion (and buffer
    >> (set-buffer buffer)) (1- (position-bytes (point-max)))))
    Stefan> This function is very unlikely to ever be useful: the
    Stefan> number of bytes to represent a particular sequence of
    Stefan> characters depends on the encoding used.  So for
    Stefan> example the result will be different for the exact
    Stefan> same text when run in Emacs-22 or in Emacs-unicode.
    Stefan> And it most likely will different from the number of
    Stefan> bytes of the file associated with the buffer.
    Stefan>         Stefan
    Stefan> _______________________________________________
    Stefan> Emacs-devel mailing list address@hidden
    Stefan> http://lists.gnu.org/mailman/listinfo/emacs-devel

Best Regards,

Email:  address@hidden
WWW:    http://emacspeak.sf.net/raman/
AIM:    emacspeak       GTalk: address@hidden
PGP:    http://emacspeak.sf.net/raman/raman-almaden.asc
Google: tv+raman 
IRC:    irc://irc.freenode.net/#emacs

reply via email to

[Prev in Thread] Current Thread [Next in Thread]