MCPcopy Create free account
hub / github.com/StackStorm/st2 / to_unicode

Function to_unicode

st2common/st2common/util/compat.py:38–53  ·  view source on GitHub ↗

Ensure that the provided text value is represented as unicode. :param value: Value to convert. :type value: ``str`` or ``unicode`` :rtype: ``unicode``

(value)

Source from the content-addressed store, hash-verified

36
37
38def to_unicode(value):
39 """
40 Ensure that the provided text value is represented as unicode.
41
42 :param value: Value to convert.
43 :type value: ``str`` or ``unicode``
44
45 :rtype: ``unicode``
46 """
47 if not isinstance(value, six.string_types):
48 raise ValueError('Value "%s" must be a string.' % (value))
49
50 if not isinstance(value, six.text_type):
51 value = six.u(value)
52
53 return value
54
55
56def to_ascii(value):

Callers 3

_processFunction · 0.90
_cast_stringFunction · 0.90
render_valuesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected