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.VorbisF ile(ogg_file)
comentarios = vorbis_file.com ment()
recognized_comm ents = ('Artist', 'Album', 'Title', 'Version',
'Organization', 'Genre', 'Description',
'Date', 'Location', 'Copyright', 'Vendor')
comment_dict = {}
for com in recognized_comm ents:
comment_dict[string.upper(co m)] = '%s: %%s' % com
known_keys = comment_dict.ke ys()
for key, val in comentarios.ite ms():
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
UnicodeEncodeEr ror: '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? 1 8151
oziko wrote: So I do not understan why the script uses an ascii codec, Am I not using Unicode coding?
The strings use Unicode, but they have to be encoded somehow to be
outputted. The default encoding is ASCII, which doesn't support all of
those fancy Unicode characters. Figure out what encoding your terminal
is expecting (probably utf-8) and encode all strings in that when
they're outputted or set a default encoding. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peter Wilkinson |
last post by:
Hello tlistmembers,
I am using the encoding function to convert unicode to ascii. At one point
this code was working just fine, however, now it has broken.
I am reading a text file that has is in unicode (I am unsure of which
flavour or bit depth). as I read in the file one line at a time
(readlines()) it converts to ascii. Simple enough. At the same time I am
copressing to bz2 with the bz2 module but that works just fine. The code...
|
by: jau |
last post by:
Hi co-listers!
I have been off Python for 2 years and now, that i'm used to Eclipse and
Java, I decided to start a project with Python to refresh skills this
time using Eclipse and TrueStudio. But now, two things can be occured
since the last time i used it.
the first one, something concerning to the encoding has changed and i
haven't noticed it.
|
by: thomas Armstrong |
last post by:
Hi
Using Python 2.3.4 + Feedparser 3.3 (a library to parse XML documents)
I'm trying to parse a UTF-8 document with special characters like
acute-accent vowels:
--------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
....
-------
|
by: ChaosKCW |
last post by:
Hi
I am reading from an oracle database using cx_Oracle. I am writing to a
SQLite database using apsw.
The oracle database is returning utf-8 characters for euopean item
names, ie special charcaters from an ASCII perspective.
I get the following error:
> SQLiteCur.execute(sql, row)
|
by: Mike Currie |
last post by:
Can anyone explain why I'm getting an ascii encoding error when I'm trying
to write out using a UTF-8 encoder?
Thanks
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> filterMap = {}
>>> for i in range(0,255):
| |
by: Thomas W |
last post by:
I'm getting really annoyed with python in regards to
unicode/ascii-encoding problems.
The string below is the encoding of the norwegian word "fødselsdag".
I stored the string as "fødselsdag" but somewhere in my code it got
translated into the mess above and I cannot get the original string
back. It cannot be printed in the console or written a plain text-file.
I've tried to convert it using
|
by: John Nagle |
last post by:
I'm trying to clean up a bad ASCII string, one read from a
web page that is supposedly in the ASCII character set but has some
characters above 127. And I get this:
File "D:\projects\sitetruth\InfoSitePage.py", line 285, in httpfetch
sitetext = sitetext.encode('ascii','replace') # force to clean ASCII
UnicodeDecodeError: 'ascii' codec can't decode byte 0x92 in position 29151:
ordinal not in range(128)
|
by: Oleg Parashchenko |
last post by:
Hello,
I'm working on an unicode-aware application. I like to use "print" to
debug programs, but in this case it was nightmare. The most popular
result of "print" was:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xXX in position
0: ordinal not in range(128)
I spent two hours fixing it, and I hope it's done. The solution is one
|
by: luca72 |
last post by:
hello i have this problem:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 8: ordinal not in range(128)
Generally i solve the problem inserting :
# -*- coding: ISO-8859-1 -*-
at the top of the file but now he don't work can you help me
thanks
Luca
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |