Revision 861
Added by Aaron Marcuse-Kubitza almost 13 years ago
strings.py | ||
---|---|---|
1 | 1 |
# String manipulation |
2 | 2 |
|
3 |
import re |
|
4 |
|
|
3 | 5 |
def to_unicode(str_): |
4 | 6 |
if isinstance(str_, unicode): return str_ |
5 | 7 |
encodings = ['utf_8', 'latin_1'] |
... | ... | |
21 | 23 |
def std_newl(str_): return str_.replace('\r\n', '\n').replace('\r', '\n') |
22 | 24 |
|
23 | 25 |
def cleanup(str_): return std_newl(str_.strip()) |
26 |
|
|
27 |
def one_line(str_): return re.sub(r'\n *', r' ', cleanup(str_)) |
Also available in: Unified diff
strings.py: Added one_line() function to make a string all on one line