more Markdown stuff
[synarere.git] / core / misc.py
blob26c8d952b40fc8249886feb8e619e599591e9815
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.
11 return string
13 if isinstance(string, unicode):
14 # The string *is* unicode, let's strip stuff from it.
15 # fancy quotes
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"'")
20 # ellipsis
21 string = string.replace(u'\u2026', u'...')
22 # return the string encoded into ascii
23 return string.encode()