guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: guile can't find a chinese named file


From: Ludovic Courtès
Subject: Re: guile can't find a chinese named file
Date: Mon, 30 Jan 2017 17:41:17 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Hey Dave!

David Kastrup <address@hidden> skribis:

> address@hidden (Ludovic Courtès) writes:

[...]

>>> ERROR: In procedure open-file: No such file or directory:
>>> "/home/hermann/Desktop/filename_\u540d\u5b57.scm"
>>
>> In C, argv is just an array of byte sequences, but in Guile,
>> (command-line) returns a list of strings, not a list of bytevectors.
>>
>> Guile decodes its arguments according to the encoding of the current
>> locale.  So if you’re in a UTF-8 locale (say, zn_CH.utf8 or en_US.utf8),
>> Guile assumes its command-line arguments are UTF-8-encoded and decodes
>> them accordingly.
>>
>> In the example above, it seems that the file name encoding was different
>> from the locale encoding, leading to this error.
>>
>> HTH!
>
> Did you actually test this?

Oops, let me clarify.

Command-line arguments are indeed decoded encoding to the locale
encoding (that’s commit ed4c3739668b4b111b38555b8bc101cb74c87c1c.)

When making a syscall like open(2), Guile converts strings to the locale
encoding.

However, in 2.0, the current locale is *not* installed; you have to
either call ‘setlocale’ explicitly (like in C), or set this environment
variable (info "(guile) Environment Variables"):

  GUILE_INSTALL_LOCALE=1

When you do that (and this will be the default in 2.2), things work as
expected:

--8<---------------cut here---------------start------------->8---
$ GUILE_INSTALL_LOCALE=1 guile λ.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /home/ludo/src/guile/λ.scm
;;; compiled 
/home/ludo/.cache/guile/ccache/2.0-LE-8-2.0/home/ludo/src/guile/λ.scm.go
hello λ!
$ locale
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER=fr_FR.utf8
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=
--8<---------------cut here---------------end--------------->8---

Sorry for the confusion!

Ludo’.




reply via email to

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