Next: , Previous: , Up: Writing C   [Contents][Index]

5.10 Quote Characters

In the C locale, the output of GNU programs should stick to plain ASCII for quotation characters in messages to users: preferably 0x22 (‘"’) or 0x27 (‘'’) for both opening and closing quotes. Although GNU programs traditionally used 0x60 (‘`’) for opening and 0x27 (‘'’) for closing quotes, nowadays quotes ‘`like this'’ are typically rendered asymmetrically, so quoting ‘"like this"’ or ‘'like this'’ typically looks better.

It is ok, but not required, for GNU programs to generate locale-specific quotes in non-C locales. For example:

printf (gettext ("Processing file '%s'..."), file);

Here, a French translation might cause gettext to return the string "Traitement de fichier ‹ %s ›...", yielding quotes more appropriate for a French locale.

Sometimes a program may need to use opening and closing quotes directly. By convention, gettext translates the string ‘"`"’ to the opening quote and the string ‘"'"’ to the closing quote, and a program can use these translations. Generally, though, it is better to translate quote characters in the context of longer strings.

If the output of your program is ever likely to be parsed by another program, it is good to provide an option that makes this parsing reliable. For example, you could escape special characters using conventions from the C language or the Bourne shell. See for example the option --quoting-style of GNU ls.