[drakma-devel] question about encodings and content length calculation

Peter Eddy peter.eddy at gmail.com
Mon Dec 17 17:45:51 UTC 2007


Hi,

I'm trying resolve a problem I'm having trying to send utf-8 data and
the calculation of the length of that data. If I make the following
post:

(defconstant +utf-8+ (make-external-format :utf-8 :eol-style :lf)

(http-request "http://odeon:5984"
                       :content-type "application/xml"
                       :external-format-out +utf-8+
                       :content "e"
                       :method :put)

The resulting request looks like this:

PUT / HTTP/1.1
Host: odeon:5984
User-Agent: Drakma/0.11.1 (OpenMCL Version 1.1-pre-070722
(DarwinX8664); Darwin; 9.1.0; http://weitz.de/drakma/)
Accept: */*
Connection: close
Content-Type: application/xml
Content-Length: 1

e

Which is right. But if I replace the "e" content with "é"  (e accent
acute), the request looks like this:

PUT / HTTP/1.1
Host: odeon:5984
User-Agent: Drakma/0.11.1 (OpenMCL Version 1.1-pre-070722
(DarwinX8664); Darwin; 9.1.0; http://weitz.de/drakma/)
Accept: */*
Connection: close
Content-Type: application/xml
Content-Length: 1

..

The hex values of the ".." are C3 A9, which is the utf-8 value for é.
The problem is, of course, that the content length is really 2.

I assume I'm doing something wrong, but I don't know what exactly that
would be. Should I be calculating the length myself?

thanks for any pointers or suggestions.

- Peter



More information about the Drakma-devel mailing list