jigdo API
Last update by Admin on 2010-05-23
util/string-utf.hh File Reference
subst("Format %1, %2", arg1, arg2) creates strings with the arguments filled in, and does so in a safer way than sprintf() and friends. More...
#include <string.hh>
Go to the source code of this file.
Detailed Description
subst("Format %1, %2", arg1, arg2) creates strings with the arguments filled in, and does so in a safer way than sprintf() and friends.This is the same functionality as in string.hh, except that UTF-8 strings are handled by subst():
- Output string is always valid UTF-8
- Format string is assumed to be in valid UTF-8
- "%F1" arg is assumed to be in valid UTF-8 (is copied over unvalidated)
- "%1" arg is untrusted UTF-8, will be validated while substituting it
- "%L1" arg is assumed to be in the OS locale, is converted into UTF-8
Additionally:
- "%E1" arg: The characters <>& are escaped with their entities < > & when substituting the value. Useful if the string will be rendered by Pango. The escaping is limited to this single substitution, the format string or other substituted values can still contain tags. NB: Newlines, tabs, delete (0x7f) etc. are not removed.
Modifiers can be combined, except that F is ignored when you use L. Modifiers only have an effect for string substitution, not for int/long/char etc.
If untrusted UTF-8 turns out to be invalid, only the valid prefix (if any) of the invalid arg is substituted.
Substituting single chars only makes sense if the char is an ASCII character.
In a nutshell:
F = fast UTF-8 string substitution
L = locale-format string
E = escape <>&
Generated on Tue Sep 23 14:27:42 2008 for jigdo by
