[Top][All Lists]

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

Re: gh_repl

From: Mark H Weaver
Subject: Re: gh_repl
Date: Mon, 09 Jan 2012 16:18:04 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Mike Gran <address@hidden> writes:
>    scm_from_locale_symbol ("scheme"));

Note that it's good practice to always use `scm_from_utf8_symbol' or
`scm_from_latin1_symbol' when the argument is a C string literal.  The
choice of which (`utf8' or `latin1') depends on the encoding of your C
source file.  Similarly, for creating strings and keywords from C string
literals, use `scm_from_{utf8,latin1}_string' or

(though unfortunately Guile 1.8 did not include any of these functions).

In this case it doesn't matter because the C string literal contains
only ASCII characters, and all locale encodings are ASCII compatible.
However, if you added non-ASCII characters to the string literal, your
program would fail unless the user's locale encoding happened to match
that of your source code.

More importantly, since many people tend to copy code snippets from what
they see here and elsewhere, it's good to start spreading good i18n
habits.  The key idea to spread is: it's wrong to use the user's locale
to interpret a C string literal.


reply via email to

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