* command line argument locale for a guile script
@ 2011-11-07 0:19 cong gu
2011-11-07 12:59 ` David Pirotte
2012-01-09 22:15 ` Andy Wingo
0 siblings, 2 replies; 7+ messages in thread
From: cong gu @ 2011-11-07 0:19 UTC (permalink / raw)
To: guile-user
When guile 2.0 is used to write scripts, one have to manually do a
setlocale at the beginning of the script to enable non-asciiI
character support (why not by default?).
My question is that the command line arguments seems to be parsed
before any code in the script is executed (including the setlocale).
Thus non-ascii arguments are not read correctly. Do I miss something
or can anybody tell me how to read arguments correctly?
My locale is en_US.UTF-8. Guile 1.8 works just fine.
$ cat test.scm
#!/usr/bin/guile
!#
(setlocale LC_ALL "")
(write (command-line))
$ ./test.scm 跪了
("./test.scm" "??????")
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: command line argument locale for a guile script
2011-11-07 0:19 command line argument locale for a guile script cong gu
@ 2011-11-07 12:59 ` David Pirotte
2011-11-07 15:31 ` cong gu
2012-01-09 22:15 ` Andy Wingo
1 sibling, 1 reply; 7+ messages in thread
From: David Pirotte @ 2011-11-07 12:59 UTC (permalink / raw)
To: cong gu; +Cc: guile-user
Hello,
> My question is that the command line arguments seems to be parsed
> ... ... or can anybody tell me how to read arguments correctly?
You must also set port encoding, see manual section 6.14.1 for details:
(set-port-encoding! (current-output-port) "utf-8")
Cheers,
David
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: command line argument locale for a guile script
2011-11-07 12:59 ` David Pirotte
@ 2011-11-07 15:31 ` cong gu
2011-11-07 19:16 ` Nala Ginrut
2011-11-07 19:16 ` Thien-Thi Nguyen
0 siblings, 2 replies; 7+ messages in thread
From: cong gu @ 2011-11-07 15:31 UTC (permalink / raw)
To: David Pirotte; +Cc: guile-user
On Mon, Nov 7, 2011 at 6:59 AM, David Pirotte <david@altosw.be> wrote:
> You must also set port encoding, see manual section 6.14.1 for details:
>
> (set-port-encoding! (current-output-port) "utf-8")
>
Thanks for responding.
But after a setlocale, utf-8 output is already fine. The problem is
argument parsing still not work for non-ascii characters.
#!/usr/bin/guile
!#
(setlocale LC_ALL "")
(set-port-encoding! (current-input-port) "utf-8")
(set-port-encoding! (current-output-port) "utf-8")
(write "跪了") ;; fine
(write (command-line)) ;; not work
After I add a setlocale to boot-9.scm, all things works. But is there
a "normal" way to fix this?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: command line argument locale for a guile script
2011-11-07 15:31 ` cong gu
@ 2011-11-07 19:16 ` Nala Ginrut
2011-11-07 19:16 ` Thien-Thi Nguyen
1 sibling, 0 replies; 7+ messages in thread
From: Nala Ginrut @ 2011-11-07 19:16 UTC (permalink / raw)
To: cong gu, guile-user
[-- Attachment #1: Type: text/plain, Size: 941 bytes --]
On Mon, Nov 7, 2011 at 11:31 PM, cong gu <gucong43216@gmail.com> wrote:
> On Mon, Nov 7, 2011 at 6:59 AM, David Pirotte <david@altosw.be> wrote:
> > You must also set port encoding, see manual section 6.14.1 for details:
> >
> > (set-port-encoding! (current-output-port) "utf-8")
> >
>
> Thanks for responding.
>
> But after a setlocale, utf-8 output is already fine. The problem is
> argument parsing still not work for non-ascii characters.
>
> #!/usr/bin/guile
> !#
> (setlocale LC_ALL "")
> (set-port-encoding! (current-input-port) "utf-8")
> (set-port-encoding! (current-output-port) "utf-8")
> (write "跪了") ;; fine
> (write (command-line)) ;; not work
>
>
> After I add a setlocale to boot-9.scm, all things works. But is there
> a "normal" way to fix this?
>
>
hi, we've talked about this problem and we think it's a real bug.
I sent a patch just now, it is solved. You may see it work soon.
[-- Attachment #2: Type: text/html, Size: 1438 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: command line argument locale for a guile script
2011-11-07 15:31 ` cong gu
2011-11-07 19:16 ` Nala Ginrut
@ 2011-11-07 19:16 ` Thien-Thi Nguyen
[not found] ` <CAPjoZodm7Zuekimv7h8DwfkzbTEQVapj6U_qRLYokRb2xsD+Zw@mail.gmail.com>
1 sibling, 1 reply; 7+ messages in thread
From: Thien-Thi Nguyen @ 2011-11-07 19:16 UTC (permalink / raw)
To: cong gu; +Cc: guile-user, David Pirotte
() cong gu <gucong43216@gmail.com>
() Mon, 7 Nov 2011 09:31:49 -0600
After I add a setlocale to boot-9.scm, all things works.
But is there a "normal" way to fix this?
Besides boot-9.scm, guile also runs init.scm (in ‘%load-path’).
Perhaps you can experiment with calling ‘setlocale’ there.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: command line argument locale for a guile script
[not found] ` <CAPjoZodm7Zuekimv7h8DwfkzbTEQVapj6U_qRLYokRb2xsD+Zw@mail.gmail.com>
@ 2011-11-07 19:24 ` Nala Ginrut
0 siblings, 0 replies; 7+ messages in thread
From: Nala Ginrut @ 2011-11-07 19:24 UTC (permalink / raw)
To: guile-user
[-- Attachment #1: Type: text/plain, Size: 574 bytes --]
On Tue, Nov 8, 2011 at 3:16 AM, Thien-Thi Nguyen <ttn@gnuvola.org> wrote:
> () cong gu <gucong43216@gmail.com>
> () Mon, 7 Nov 2011 09:31:49 -0600
>
> After I add a setlocale to boot-9.scm, all things works.
> But is there a "normal" way to fix this?
>
> Besides boot-9.scm, guile also runs init.scm (in ‘%load-path’).
> Perhaps you can experiment with calling ‘setlocale’ there.
>
>
I think it's too early to call setlocale so that "locale_charset" can not
realize current locale in time.
I didn't test this method, but it's no hurt to try. ;-)
[-- Attachment #2: Type: text/html, Size: 1046 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: command line argument locale for a guile script
2011-11-07 0:19 command line argument locale for a guile script cong gu
2011-11-07 12:59 ` David Pirotte
@ 2012-01-09 22:15 ` Andy Wingo
1 sibling, 0 replies; 7+ messages in thread
From: Andy Wingo @ 2012-01-09 22:15 UTC (permalink / raw)
To: cong gu; +Cc: guile-user
On Mon 07 Nov 2011 01:19, cong gu <gucong43216@gmail.com> writes:
> When guile 2.0 is used to write scripts, one have to manually do a
> setlocale at the beginning of the script to enable non-asciiI
> character support (why not by default?).
For the record, this will be fixed in the upcoming 2.0.4.
Thanks for the report and discussion.
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-01-09 22:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-07 0:19 command line argument locale for a guile script cong gu
2011-11-07 12:59 ` David Pirotte
2011-11-07 15:31 ` cong gu
2011-11-07 19:16 ` Nala Ginrut
2011-11-07 19:16 ` Thien-Thi Nguyen
[not found] ` <CAPjoZodm7Zuekimv7h8DwfkzbTEQVapj6U_qRLYokRb2xsD+Zw@mail.gmail.com>
2011-11-07 19:24 ` Nala Ginrut
2012-01-09 22:15 ` Andy Wingo
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).