Mercurial > public > sg101
diff gpp/legacy/phpbb.py @ 294:254db4cb6a86
Changes / scripts to import forums. Other tweaks and moving other import scripts to the legacy application.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 05 Jan 2011 04:09:35 +0000 |
parents | 64c188a9d31f |
children |
line wrap: on
line diff
--- a/gpp/legacy/phpbb.py Wed Dec 29 04:56:53 2010 +0000 +++ b/gpp/legacy/phpbb.py Wed Jan 05 04:09:35 2011 +0000 @@ -48,7 +48,7 @@ return re.sub("&#?\w+;", fixup, text) -def unphpbb(s): +def unphpbb(s, encoding='latin-1'): """Converts BBCode from phpBB database data into 'pure' BBCode. phpBB doesn't store plain BBCode in its database. The BBCode tags have @@ -56,9 +56,12 @@ This function removes the uid stuff and undoes the entity'ification and returns the result as a unicode string. + If the input 's' is not already unicode, it will be decoded using the + supplied encoding. + """ if not isinstance(s, unicode): - s = s.decode('utf-8', 'replace') + s = s.decode(encoding, 'replace') for start, end in BBCODE_RES: s = re.sub(start, r'\1', s, re.MULTILINE) s = re.sub(end, r'\1]', s, re.MULTILINE)