[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with UTF-8, "write, " and some characters using initial loca
From: |
Taylor Venable |
Subject: |
Re: Problem with UTF-8, "write, " and some characters using initial locale |
Date: |
Sat, 20 Nov 2010 15:34:06 -0500 |
On Sat, Nov 20, 2010 at 12:53 PM, Mike Gran <address@hidden> wrote:
> You should basically always call (setlocale LC_ALL "") before
> working on non-ASCII code.
>
> Guile starts up in Latin-1. It may seem that Guile should
> pick up your environment's LANG or LOCALE on startup, but, most
> compilers (including gcc) don't do that by default.
>
> When you call setlocale, Guile picks up thelocale of your session.
>
> So, in your first line in your example, you pasted in a string of
> utf-8 text. Guile read it in raw bytes and never tried to unpack
> those bytes into Unicode characters. You can prove it to youself by
> passing your string to the string-length procedure. You'll get
> the length of the utf-8 bytes of your string, not the actual number
> of characters.
>
> The weird escapes come from trying to write a string of utf-8 bytes
> in the latin-1 encoding. The latin-1 characters from 0x80 to 0x9F
> are the ISO-8859-1 C1 control characters and not printable.
> So, (write) prints them as escapes instead.
Oh, I see now! I hadn't thought of it like that, thanks for the explanation.
--
Taylor C. Venable
http://metasyntax.net/