1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add a function to change output from a str to unicode

This commit is contained in:
Toshio Kuratomi 2015-02-02 18:28:47 -08:00
parent 5d1e468bda
commit d50089ca9f

View file

@ -241,3 +241,8 @@ def to_bytes(obj, encoding='utf-8', errors='replace', nonstring=None):
raise TypeError('nonstring value, %(param)s, is not set to a valid'
' action' % {'param': nonstring})
# force the return value of a function to be unicode. Use with partial to
# ensure that a filter will return unicode values.
def unicode_wrap(func, *args, **kwargs):
return to_unicode(func(*args, **kwargs), nonstring='passthru')