From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.user Subject: Re: displaying UTF8 characters in and out of a script (guile 2.0.5) Date: Sun, 16 Dec 2012 15:31:19 -0500 Message-ID: <871uep4u3s.fsf@tines.lan> References: <1355685754.7015.140661166743981.0F8ECFCA@webmail.messagingengine.com> <20121216180452.0820b094@capac> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1355689917 19630 80.91.229.3 (16 Dec 2012 20:31:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 16 Dec 2012 20:31:57 +0000 (UTC) Cc: guile-user@gnu.org, David Pirotte To: msematman@myopera.com Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Dec 16 21:32:09 2012 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TkKsb-0001RX-Hy for guile-user@m.gmane.org; Sun, 16 Dec 2012 21:32:09 +0100 Original-Received: from localhost ([::1]:49480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkKsO-0002c1-Bd for guile-user@m.gmane.org; Sun, 16 Dec 2012 15:31:56 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:32918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkKsI-0002ZE-JE for guile-user@gnu.org; Sun, 16 Dec 2012 15:31:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkKsH-0001fE-A3 for guile-user@gnu.org; Sun, 16 Dec 2012 15:31:50 -0500 Original-Received: from world.peace.net ([96.39.62.75]:54320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkKsH-0001dj-5i for guile-user@gnu.org; Sun, 16 Dec 2012 15:31:49 -0500 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1TkKrz-0000iy-Qa; Sun, 16 Dec 2012 15:31:31 -0500 In-Reply-To: <20121216180452.0820b094@capac> (David Pirotte's message of "Sun, 16 Dec 2012 18:04:52 -0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 96.39.62.75 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9747 Archived-At: David Pirotte writes: >> However, the same command in a script: >>=20 >> #!/usr/bin/guile \ >> -s >> #! >> (display "=C4=86i=C4=87olina") >>=20 >> 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