September 17, 2006

SBCL Unicode and locales

I've been playing with Unicode support in SBCL lately, so I keep an ear out on the mailing lists for gotchas. On comp.lang.lisp, SBCL+UFFI+MYSQL came up and here's the tidbit:

Yay! That's it!

When I ran this:

 (stream-external-format *standard-output*)

I got :LATIN-1 as a response.

So, I exited SBCL and did:

 export LC_CTYPE=en_US.UTF-8

Started SBCL again and checked the external-format. Got :UTF-8.
Promising!

Ran my database setup stuff and executed a query that should return
UTF-8 encoded data.

It worked! "правда" in all its glory! :)

Moral of the story: Make sure you know what locale SBCL is using. You will get a reader error if SBCL is using Latin-1 and tries to read Unicode, but it's great to know why and how to fix it.

Posted by cbrown at September 17, 2006 1:44 PM