From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: slime and lisp buffer encoding
Date: Fri, 07 Aug 2009 15:10:12 +0200 [thread overview]
Message-ID: <7cprb7rcqz.fsf@pbourguignon.anevia.com> (raw)
In-Reply-To: 2b178719-3db9-4bde-98b0-3ce087614ca6@v23g2000pro.googlegroups.com
Eric <girzel@gmail.com> writes:
> On Aug 7, 5:52 pm, Eric Abrahamsen <gir...@gmail.com> wrote:
>> Hi,
>>
>> I'm using Emacs and slime to do a bit of hunchentoot (lisp web server)
>> development, and I'm running into an encoding problem. I don't know
>> which of the links in the chain is causing the problem, so I hope
>> someone here will see what's going...
>>
>> Basically, using hunchentoot (with cl-who for html templating)
>> involves writing the html templates directly into the source code, and
>> I'm discovering that I can't type utf-8 text into these source files.
>> Compiling a defun with unicode in it results in an encoding error (I
>> believe thrown by slime as the defun gets sent to the repl).
>>
>> I have set everything I can set (file, keyboard, subprocess IO) to
>> utf-8-unix. The weird thing is, I can type a Latin accented a (à) into
>> the source without trouble. Hunchentoot seems to use a CONTENT-TYPE of
>> iso-8859-1 by default, in which case the à shows up fine in the
>> browser. If I set content type to utf-8, my browser garbles the à. So
>> my lisp strings must be encoded as iso-8859-1, but how did they get
>> that way? And how do I make them utf-8?
>
> I'll answer my own question: They got that way because iso-8859-1 is
> the default string encoding for OpenMCL. Altering inferior-lisp-
> program to add the option "-K utf-8" after the executable results in a
> lisp that runs in utf-8 by default. Apologies for the noise.
Moreover, you have to set things up in hunchetoot to send utf-8 data.
Some browser may accept a page declared as iso-8859-1 that actually
contain utf-8 data because it's an error often made, but you will want
to send headers and meta tags matching your data.
* I put on the first line of all my lisp sources:
;;;; -*- mode:lisp;coding:utf-8 -*-
(you may configure emacs to do that my default, but I like it that
the encoding be "documented" this way in the files).
* I confnigure hunchentoot to use utf-8 by default:
(defparameter *utf-8*
(flex:make-external-format :utf-8 :eol-style :lf)
"The UTF-8 encoding.")
(setf hunchentoot:*HUNCHENTOOT-DEFAULT-EXTERNAL-FORMAT* *utf-8*
hunchentoot:*DEFAULT-CONTENT-TYPE* "text/html; charset=UTF-8")
* In addition in all the pages I build, I put in the <head> section a
<meta http-equiv="Content-Type" content="text/html; charset=utf-8>
tag.
You can check that everything is ok with Firefox "Page Info" menu item
(I don't remember in what menu).
--
__Pascal Bourguignon__
next prev parent reply other threads:[~2009-08-07 13:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.4108.1249638780.2239.help-gnu-emacs@gnu.org>
2009-08-07 10:23 ` slime and lisp buffer encoding Eric
2009-08-07 13:10 ` Pascal J. Bourguignon [this message]
2009-08-07 10:26 ` Giovanni Lanzani
2009-08-07 9:52 Eric Abrahamsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7cprb7rcqz.fsf@pbourguignon.anevia.com \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).