Marko Rauhamaa <[email protected]> writes: > [email protected] (Ludovic Courtès): > >> 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. > > I'm afraid that choice (which Python made, as well) was a bad one > because Linux doesn't guarantee UTF-8 purity.
Have you looked at the error messages? They are all perfect UTF-8. As was the command line locale. Here, have another data point: dak@lola:/usr/local/tmp/lilypond$ guile-2.0 /tmp/f♯.scm ;;; Stat of /tmp/f?.scm failed: ;;; ERROR: In procedure stat: No such file or directory: "/tmp/f\u266f.scm" Backtrace: In ice-9/boot-9.scm: 160: 8 [catch #t #<catch-closure 9ca5710> ...] In unknown file: ?: 7 [apply-smob/1 #<catch-closure 9ca5710>] In ice-9/boot-9.scm: 66: 6 [call-with-prompt prompt0 ...] In ice-9/eval.scm: 432: 5 [eval # #] In ice-9/boot-9.scm: 2404: 4 [save-module-excursion #<procedure 9cb6ce0 at ice-9/boot-9.scm:4051:3 ()>] 4056: 3 [#<procedure 9cb6ce0 at ice-9/boot-9.scm:4051:3 ()>] 1727: 2 [%start-stack load-stack ...] 1732: 1 [#<procedure 9cbc690 ()>] In unknown file: ?: 0 [primitive-load "/tmp/f\u266f.scm"] ERROR: In procedure primitive-load: ERROR: In procedure open-file: No such file or directory: "/tmp/f\u266f.scm" dak@lola:/usr/local/tmp/lilypond$ guile-2.0 GNU Guile 2.0.13 Copyright (C) 1995-2016 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> (open-input- open-input-file open-input-string scheme@(guile-user)> (open-input-file "/tmp/f\u266f.scm") $1 = #<input: /tmp/f♯.scm 9> scheme@(guile-user)> (open-input-file "/tmp/non-existent") ERROR: In procedure open-file: ERROR: In procedure open-file: No such file or directory: "/tmp/non-existent" Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guile-user) [1]> Apparently, Guile can open the file just fine, and it sees the command line just fine as encoded in utf-8. But during command line processing rather than afterwards, it fails opening the file. So I really, really, really suggest that before people post their theories that they actually bother cross-checking them with Guile. -- David Kastrup
