unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: msematman@myopera.com
To: Mark H Weaver <mhw@netris.org>
Cc: guile-user@gnu.org, David Pirotte <david@altosw.be>
Subject: Re: displaying UTF8 characters in and out of a script (guile 2.0.5)
Date: Mon, 17 Dec 2012 13:18:14 +0100	[thread overview]
Message-ID: <1355746694.17729.140661167007929.19DCB030@webmail.messagingengine.com> (raw)
In-Reply-To: <871uep4u3s.fsf@tines.lan>



On Sun, Dec 16, 2012, at 09:31 PM, Mark H Weaver wrote:
> David Pirotte <david@altosw.be> 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

-- 
  
  msematman@myopera.com



  reply	other threads:[~2012-12-17 12:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-16 19:22 displaying UTF8 characters in and out of a script (guile 2.0.5) msematman
2012-12-16 20:04 ` David Pirotte
2012-12-16 20:31   ` Mark H Weaver
2012-12-17 12:18     ` msematman [this message]
2013-01-13 11:02     ` Andy Wingo
2013-01-13 18:12       ` Mark H Weaver
2013-01-13 22:09       ` Ludovic Courtès

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/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355746694.17729.140661167007929.19DCB030@webmail.messagingengine.com \
    --to=msematman@myopera.com \
    --cc=david@altosw.be \
    --cc=guile-user@gnu.org \
    --cc=mhw@netris.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).