make-alpha
[Top][All Lists]
Advanced

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

Re: Guile integration and UTF-8


From: Ludovic Courtès
Subject: Re: Guile integration and UTF-8
Date: Tue, 24 Sep 2013 23:11:12 +0200
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

Hi,

Lars Ljung <address@hidden> skribis:

> 2) This simple example fails because of the UTF-8 string:
>
> all:
>       @echo $(guile "Hej, världen!")
>
> The result is:
>
> ERROR: Unknown object: "Hej, världen!".

Make uses ‘scm_c_eval_string’, which expects to be passed a string in
the current locale encoding.

So, if you have a UTF-8-encoded Makefile, but run ‘make’ with a
ISO-8859-1 locale, the string will be incorrectly decoded.

In particular, ‘to-string-maybe’ in gmk-default.scm will consider that
some characters are not printable, leading to the “Unknown object” error.

The fix would be to convert the string passed to $(guile ...) from a
fixed encoding, rather than from the current locale encoding.  For
instance:

  scm_eval_string (scm_from_utf8_string (argv[0]))

Better yet, use ‘scm_file_encoding’ to determine the encoding of a
makefile based on the presence of -*- coding -*- cookies (info "(guile)
Character Encoding of Source Files").

HTH,
Ludo’.



reply via email to

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