From 97d2738569c4fcbbfa27850d404952b6334dc130 Mon Sep 17 00:00:00 2001 From: Prodesire Date: Fri, 13 Oct 2017 20:10:45 +0800 Subject: [PATCH] add doc for safeunicode --- docs/index.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index ba9e470..782efc3 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -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'中文'