emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] url: Wrap cookie headers in url-http--encode-string.


From: Stefan Monnier
Subject: Re: [PATCH] url: Wrap cookie headers in url-http--encode-string.
Date: Fri, 09 Sep 2016 11:06:38 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

> (string-bytes cookie-val)
> => 131

This says that the internal representation of the cookie-val string uses
up 131 bytes.

> (string-bytes (encode-coding-string "æøå" 'utf-8))
> => 6

Note that `length' should return the same value, since the string
returned by encode-coding-string should be unibyte (i.e. is a sequence of
bytes, rather than sequence of characters).

> (string-bytes (concat (encode-coding-string "æøå" 'utf-8) cookie-val))
> => 143 ' why?

Because the concatenation needs to convert the bytes held in the first
string into chars.  The internal representation of bytes >=128 as chars
takes up 2 bytes.


        Stefan




reply via email to

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