Next: , Previous: Character Set, Up: Writing C


5.10 Quote Characters

In the C locale, GNU programs should stick to plain ASCII for quotation characters in messages to users: preferably 0x60 (¡`¢) for left quotes and 0x27 (¡'¢) for right quotes. It is ok, but not required, to use locale-specific quotes in other locales.

The Gnulib quote and quotearg modules provide a reasonably straightforward way to support locale-specific quote characters, as well as taking care of other issues, such as quoting a filename that itself contains a quote character. See the Gnulib documentation for usage details.

In any case, the documentation for your program should clearly specify how it does quoting, if different than the preferred method of ¡`¢ and ¡'¢. This is especially important if the output of your program is ever likely to be parsed by another program.

Quotation characters are a difficult area in the computing world at this time: there are no true left or right quote characters in Latin1; the ¡`¢ character we use was standardized there as a grave accent. Moreover, Latin1 is still not universally usable.

Unicode contains the unambiguous quote characters required, and its common encoding UTF-8 is upward compatible with Latin1. However, Unicode and UTF-8 are not universally well-supported, either.

This may change over the next few years, and then we will revisit this.