TITLE: internationalized printf (Newsgroups: comp.lang.c++.moderated, 28 July 99) KANZE: James.Kanze@dresdner-bank.com >> On the other hand, printf is typically internationalized (although >> this is formally an extension, and not part of the C standard); in >> practice, you can't use iostream when you need internationalization. RUSS: lruss@superlink.net > Sorry, maybe I don't understand what you mean, but isn't locale > used for internationalization? KANZE: Locale covers several aspects of internationalization, plus a number of other issues like conversions between internal and external format. Like the standard printf (as defined by ISO 9899), however, it is missing one of the most important parts: position independant arguments. X/Open defined an extension to do this with printf; I find it incredible that WG14 hasn't standardized this extension. The syntax of iostream pretty much makes such an extension impossible (and in fact, pretty much makes solving the problem using iostream-like output impossible). For those unaware of the problem: word order varies between languages, and so a text in English "xxx 1.45 yyy 23 zzz" might become "zzz 23 yyy 1.45 xxx" in German or French. The X/Open extension to printf allows specifying which argument to use in the format specifier, e.g. "%2$2d" instead of simple "%2d". For example, for the above text, the English string might read "xxx %4.2f yyy %2d zzz"; translated to German or French, it could be "zzz %2$2d yyy %1$4.2f zzz". Notice that you still pass the floating point value as the first argument, and the integer as the second.