xoutil.eight.text
- TODO¶
Text handling, strings can be part of internationalization processes.
See String Ambiguity in Python for more information.
New in version 1.8.0.
-
xoutil.eight.text.
force
(buffer, encoding=None)[source]¶ Convert any value to standard text type in a safe way.
The standard text type is
unicode
in Python 2 andstr
in Python 3.
-
xoutil.eight.text.
safe_join
(separator, iterable, encoding=None)[source]¶ Similar to join method in string objects.
The semantics is equivalent to
separator.join(iterable)
but forcing separator and items to be the valid instances of standard text type (unicode
in Python 2 andstr
in Python 3).For example:
>>> safe_join('-', range(6)) '0-1-2-3-4-5'
Check that the expression
'-'.join(range(6))
raises aTypeError
.Parameters: encoding – used to allow control, but won’t be common to use it.