%n$ conversion specifications
Earlier we noted that the %n$ form of
conversion specification lets you convert the nth
argument in a printf or scanf
argument list rather than the next unused argument.
We showed you how you could use the feature
to control the format of the date and time
in different locales, and suggested that %n$
had a wider
application than that.
What we had in mind were cases in which the rules
of a given language were built into print statements such as
func == MAP ? "Can't map" : "Can't create", pathname);
The problem with this code
is that it assumes that the verb precedes the object of the sentence,
which is not the case in many languages.
In other words, even if we rewrote the fragment to use gettxt,
and stored translations of the strings in
message files in the appropriate locales,
we would still want to use the %n$
conversion specification to switch the arguments
to printf depending on the locale.
That is, the printf format string
in an English-language locale would be written
in a locale in which the object of the sentence precedes the predicate.
gencat and catgets (X/Open)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004