[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: displaying UTF8 characters in and out of a script (guile 2.0.5)
From: |
msematman |
Subject: |
Re: displaying UTF8 characters in and out of a script (guile 2.0.5) |
Date: |
Mon, 17 Dec 2012 13:18:14 +0100 |
On Sun, Dec 16, 2012, at 09:31 PM, Mark H Weaver wrote:
> David Pirotte <address@hidden> writes:
>
> >> However, the same command in a script:
> >>
> >> #!/usr/bin/guile \
> >> -s
> >> #!
> >> (display "Ćićolina")
> >>
> >> writes this out: ?i?olina
> >
> > you need to set the port encoding first [for further info see section
> > '6.14.1 Ports'
> > of the manual]:
>
> Unfortunately that is only a partial solution (it changes the encoding
> of the current-output-port only, not for anything else), and it assumes
> that the user wants UTF-8 output.
>
> A more comprehensive solution is to put this:
>
> (setlocale LC_ALL "")
>
> at the beginning of the script, which will set the locale according to
> the user's settings (as specified by the environment variables). This
> is what Guile does when starting an interactive session, and what most
> other interactive programs and scripting languages do as well.
>
> Also, since your script contains non-ASCII characters, you should place
> a coding declaration in the file so that Guile will know what encoding
> to use when reading it. If your script is in UTF-8, then put this in
> the first 500 characters of the file:
>
> ;;; coding: utf-8
>
> For more details, see:
>
>
> http://www.gnu.org/software/guile/manual/html_node/Character-Encoding-of-Source-Files.html
>
> If you do these things, then your script should work properly even when
> run by a user who has configured a non-UTF-8 locale.
>
> Regards,
> Mark
David, Mark,
Thanks for the detailed explanation, it works now.
Cheers
--
address@hidden