msg can work

This commit is contained in:
ppwwyyxx
2014-11-21 14:09:09 +08:00
parent 68c0e92aac
commit 83040b8a8d
5 changed files with 89 additions and 18 deletions
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
# File: utils.py
# Date: Fri Nov 21 13:42:56 2014 +0800
# Author: Yuxin Wu <[email protected]>
def ensure_bin_str(s):
if type(s) == str:
return s
if type(s) == unicode:
return s.encode('utf-8')
def ensure_unicode(s):
if type(s) == str:
return s.decode('utf-8')
if type(s) == unicode:
return s