Comment 5 for bug 135985

Revision history for this message
Jiahua Huang (huangjiahua) wrote :

Hi, it's my new patch

=== modified file 'xl/metadata/_id3.py'
--- xl/metadata/_id3.py 2009-08-25 21:35:45 +0000
+++ xl/metadata/_id3.py 2009-10-09 11:33:58 +0000
@@ -31,6 +31,20 @@ from mutagen import id3
 import logging
 logger = logging.getLogger(__name__)

+import locale
+if str(locale.getdefaultlocale()[0]).startswith('zh'):
+ _unicode=unicode
+ def unicode(string, encoding='utf8',errors='strict'):
+ try:
+ string = string.decode('utf8').encode('iso8859-1')
+ except:
+ return _unicode(string)
+ for enc in ('utf8', 'gb2312', 'big5', 'gb18030', 'big5hkscs', 'euc-jp', 'euc_kr', 'cp1251', 'utf16'):
+ try:
+ return string.decode(enc)
+ except:
+ pass
+ return string

 class ID3Format(BaseFormat):
     MutagenType = id3.ID3