4 ms·
POSIX printf allows a translator to write a conversion spec like "%1$d" that says which arg to print. This lets you do stuff like put currency before or after t
by prodigal_erik 11y ago
POSIX printf allows a translator to write a conversion spec like "%1$d" that says which arg to print. This lets you do stuff like put currency before or after the amount depending on what's idiomatic for the locale, without recompiling (if you lookup your format strings at runtime).
- simoncion 11y agoSure, but that's l10n, which is a different -but related- thing. :) printf format strings are well thought-out. I was demonstrating that the same ideas can easily be used with io*stream.
- simoncion 11y agoFor the downvoters: Here's a lib that accomplishes this task that's had a fair bit more than 10 seconds of thought put into it: [0]. Examples [1][2]. :) [0] http://www.boost.org/doc/libs/1_60_0/libs/locale/doc/html/index.html http://www.boost.org/doc/libs/1_60_0/libs/locale/doc/html/in... [1] http://www.boost.org/doc/libs/1_60_0/libs/locale/doc/html/hello_8cpp-example.html http://www.boost.org/doc/libs/1_60_0/libs/locale/doc/html/he... [2] http://www.boost.org/doc/libs/1_60_0/libs/locale/doc/html/messages_formatting.html http://www.boost.org/doc/libs/1_60_0/libs/locale/doc/html/me...