Character coding problem with gblogger

3 views
Skip to first unread message

Joseph Fahey

unread,
Jun 26, 2007, 10:31:33 AM6/26/07
to emacs-g-client
Hi,

I've been trying to blog using g-client. Everything works perfectly as
long as I don't use accented characters.

Whenever I use accented characters, I get the following message:

HTTP/1.1 400 Bad Request
Content-Type: text/plain
Transfer-Encoding: chunked
Cache-control: private
Date: Tue, 26 Jun 2007 14:24:52 GMT
Server: GFE/1.3

org.xml.sax.SAXParseException: The element type "entry" must
be terminated by the matching end-tag "</entry>".

I've tried to track down the problem and it seems that the character
coding problem occurs when g-client sends the buffer contents to the
XSLT processor (the function "g-xsl-transform-region").

I've tried to put everything I can (buffers, buffer output, etc.) into
UTF-8, but nothing I have tried seems to make much difference. I wrote
up what I have tried so far for the gnu.emacs.help group, but it seems
my post created more questions than it answered...

http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/904f4dd1d02cf174/96064f1ac97dadfc?lnk=st&q=gnu+emacs+help+fahey&rnum=1#96064f1ac97dadfc

Any ideas on where I should look and what I should try?

Thanks,

Joe

condotti

unread,
Jun 26, 2007, 10:48:16 PM6/26/07
to emacs-g-client
Hi,
In the function gblogger-send-buffer-contents, the Content-length
header is set to (buffer-size), the number of characters in the
buffer. If you send multibyte characters ie. utf-8, you should set the
number of bytes instead. I changed (buffer-size) as follows:

(string-bytes
(encode-coding-string
(buffer-substring-no-properties (point-min) (point-max)) 'utf-8-
unix))

It seems working for me.

Joseph Fahey

unread,
Jun 27, 2007, 3:34:33 PM6/27/07
to emacs-g-client

Brilliant! It works!

Many thanks.

Joe

ramanraman

unread,
Jun 28, 2007, 10:28:53 AM6/28/07
to emacs-g-client
Thank you for spotting this. Your fix looks correct, but it might
end up consing memory -- could you try this alternative?

Function position-bytes in Emacs 22 might be more optimal for
this --
try something like
(defsubst buffer-bytes (buffer)
"Return number of bytes in a buffer."
(save-excursion
(set-buffer buffer)
(position-bytes (point-max))))

If this works, I'll check it in; I cannot test this readily since
it is not easy for me to work in a unicode environment.

condotti

unread,
Jun 28, 2007, 9:58:30 PM6/28/07
to emacs-g-client
(position-bytes (point-max)) returns the number of bytes plus 1, where
the next character will be inserted. So I made it as follows:

(defsubst buffer-bytes (buffer)
"Return number of bytes in a buffer."
(save-excursion
(set-buffer buffer)

(1- (position-bytes (point-max)))))

and it works fine so far. Thanks.

Reply all
Reply to author
Forward
0 new messages