'ascii' codec can't encode character u'\xf3'
oziko
oziko at fusiondementes.com
Mon Aug 16 14:08:32 EDT 2004
Hi, I get a piece of code of ogg123.py from the pyogg site, this is the
code:
*******************************
ogg_file = sys.argv[1]
vorbis_file=ogg.vorbis.VorbisFile(ogg_file)
comentarios = vorbis_file.comment()
recognized_comments = ('Artist', 'Album', 'Title', 'Version',
'Organization', 'Genre', 'Description',
'Date', 'Location', 'Copyright', 'Vendor')
comment_dict = {}
for com in recognized_comments:
comment_dict[string.upper(com)] = '%s: %%s' % com
known_keys = comment_dict.keys()
for key, val in comentarios.items():
if key in known_keys:
print comment_dict[key] % val
else:
continue
#print "Unknown comment: %s" % val
****************************
When I run int I get this error:
Album: Trapos
Vendor: Xiph.Org libVorbis I 20020717
Artist: Attaque 77
Traceback (most recent call last):
File "./ogg2sql.py", line 51, in ?
print comment_dict[key] % val
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in
position 15: ordinal not in range(128)
The title of the song has especial carateres Title= Perfección, it is in
espanish. I put at the begining og the scrpit the encodign coment
#!/usr/bin/env python
# -*- coding: UTF8 -*-
As you see the script get the comment og a vorbis file, and all the
comments are in unicode.
So I do not understan why the script uses an ascii codec, Am I not using
Unicode coding?
More information about the Python-list
mailing list