1 # synarere -- a highly modular and stable IRC bot.
2 # Copyright (C) 2010 Michael Rodriguez.
3 # Rights to this code are documented in docs/LICENSE.
5 '''Miscellaneous functions.'''
7 def stripunicode(string
):
8 '''Strip unicode from a string.'''
9 if isinstance(string
, str):
10 # If the string is just a string without any unicode, just return it.
13 if isinstance(string
, unicode):
14 # The string *is* unicode, let's strip stuff from it.
16 string
= string
.replace(u
'\u201c', u
'"')
17 string
= string
.replace(u
'\u201d', u
'"')
18 string
= string
.replace(u
'\u2018', u
"'")
19 string
= string
.replace(u
'\u2019', u
"'")
21 string
= string
.replace(u
'\u2026', u
'...')
22 # return the string encoded into ascii
23 return string
.encode()