guile-user
[Top][All Lists]
Advanced

[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: Mark H Weaver
Subject: Re: displaying UTF8 characters in and out of a script (guile 2.0.5)
Date: Sun, 16 Dec 2012 15:31:19 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]