Part of lp.translations.browser
Class | UnrecognisedCFormatString | Exception: C-style format string fails to parse. |
Function | contract_rosetta_escapes | Replace Rosetta escape sequences with the real characters. |
Function | expand_rosetta_escapes | Replace characters needing a Rosetta escape sequences. |
Function | text_to_html | Convert a unicode text to a HTML representation. |
Function | convert_newlines_to_web_form | Convert Unicode string to CR/LF line endings as used in web forms. |
Function | count_lines | Count the number of physical lines in a string. |
Function | parse_cformat_string | Parse C-style format string into sequence of segments. |
Any style of line endings is accepted: MacOS-style CR, MS-DOS-style CR/LF, or rest-of-world-style LF.
This is always at least as large as the number of logical lines in a string.
The result is a sequence of tuples (type, content), where type is either "string" (for a plain piece of string) or "interpolation" (for a printf()-style substitution). The other part of the tuple, content, will be the part of the input string that makes up the given element, so either plain text or a printf substitution such as %s or %.3d.
As in printf(), the double parenthesis (%%) is taken as plain text.