diff options
author | jerous <jerous@gmail.com> | 2008-09-27 19:25:33 +0200 |
---|---|---|
committer | jerous <jerous@gmail.com> | 2008-09-27 19:25:33 +0200 |
commit | a20eadadeb4cb8ec95204e76b7249100265645cc (patch) | |
tree | 27c1ee249ef6396fb7b045c3c4e343949ab7f9da /misc.py | |
parent | 0d431b71d0936294676a4d8aef85aeb0777d6171 (diff) |
better unicode (utf-8) support
Diffstat (limited to 'misc.py')
-rw-r--r-- | misc.py | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -2,6 +2,7 @@ from PyQt4 import QtCore, QtGui import re import urllib2, httplib, cookielib import socket +import unicodedata import format import log @@ -33,10 +34,13 @@ def unique(seq): seen = [] return t(c for c in seq if not (c in seen or seen.append(c))) +def toAscii(ustr): + return unicodedata.normalize('NFKD', ustr).encode('ascii', 'ignore') + def fetch(SE, sites, song=None, xtra_tags={}): """Returns None when nothing found, or [site,source-url].""" f=format.compile(SE) - SE_url=f(format.params(song, xtra_tags)) + SE_url=toAscii(f(format.params(song, xtra_tags))) SE_url=SE_url.replace(' ', '+') request=urllib2.Request(SE_url) |