add doc for safeunicode

This commit is contained in:
Prodesire 2017-10-13 20:10:45 +08:00
parent 8063e651fa
commit 97d2738569
1 changed files with 11 additions and 0 deletions

View File

@ -191,3 +191,14 @@ String
>>> strips('foobarfoo', 'foo')
'bar'
.. function:: pydu.utils.safeunicode(obj, encoding='utf-8')
Converts any given object to unicode string.
>>> safeunicode('hello')
u'hello'
>>> safeunicode(2)
u'2'
>>> safeunicode('\xe4\xb8\xad\xe6\x96\x87')
u'中文'