473,379 Members | 1,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

DeprecationWarning: Non-ASCII character '\xc0'

Hello All,

I have this file and when I import the file in the python interpretor
I get the following error:

"__main__:1: DeprecationWarning: Non-ASCII character '\xc0' in file
trans.py on line 11, but no encoding declared; see
http://www.python.org/peps/pep-0263.html for details"

I am not sure what encoding to use. I am not sure where to look. I
picked one out of the documentation. Here is what I used:
# -*- coding: utf-8 -*-

Questions:
1) Is there a list I can pick the encoding from?
2) How can I find more about encoding?

Thanks, Ahsan
Here are contents of the file:
#!/usr/bin/python
"""This module defines various general purpose translations, such as
an upper ASCII to lower ASCII map.
"""
# -*- coding: utf-8 -*-
__revision__ = '$Id: trans.py,v 1.6 2001/10/25 17:43:49 estep Exp $'

UPPER_ASCII_MAP = {
'"':'"', '"' :'"',
'&':'&', '&' :'&',
'À':'A', '<\\\#203>':'A', '&Agrave;':'A', '':'A',
'Á':'A', '<\\\#231>':'A', '&Aacute;':'A', '':'A',
'Â':'A', '<\\\#229>':'A', '&Acirc;' :'A', '':'A',
'Ã':'A', '<\\\#204>':'A', '&Atilde;':'A', '':'A',
'Ä':'A', '<\\\#128>':'A', '&Auml;' :'A', '':'A',
'Å':'A', '<\\\#129>':'A', '&Aring;' :'A', '':'A',
'Ç':'C', '<\\\#130>':'C', '&Ccedil;':'C', '':'C',
'È':'E', '<\\\#233>':'E', '&Egrave;':'E', '':'E',
'É':'E', '<\\\#131>':'E', '&Eacute;':'E', '':'E',
'Ê':'E', '<\\\#230>':'E', '&Ecirc;' :'E', '':'E',
'Ë':'E', '<\\\#232>':'E', '&Euml;' :'E', '':'E',
'Ì':'I', '<\\\#237>':'I', '&Igrave;':'I', '':'I',
'Í':'I', '<\\\#234>':'I', '&Iacute;':'I', '':'I',
'Î':'I', '<\\\#235>':'I', '&Icirc;' :'I', '':'I',
'Ï':'I', '<\\\#236>':'I', '&Iuml;' :'I', '':'I',
'Ñ':'N', '<\\\#132>':'N', '&Ntilde;':'N', '':'N',
'Ò':'O', '<\\\#241>':'O', '&Ograve;':'O', '':'O',
'Ó':'O', '<\\\#238>':'O', '&Oacute;':'O', '':'O',
'Ô':'O', '<\\\#239>':'O', '&Ocirc;' :'O', '':'O',
'Õ':'O', '<\\\#205>':'O', '&Otilde;':'O', '':'O',
'Ö':'O', '<\\\#133>':'O', '&Ouml;' :'O', '':'O',
'Ø':'O', '<\\\#175>':'O', '&Oslash;':'O', '':'O',
'Ù':'U', '<\\\#244>':'U', '&Ugrave;':'U', '':'U',
'Ú':'U', '<\\\#242>':'U', '&Uacute;':'U', '':'U',
'Û':'U', '<\\\#243>':'U', '&Ucirc;' :'U', '':'U',
'Ü':'U', '<\\\#134>':'U', '&Uuml;' :'U', '':'U',
'Ý':'Y', '&Yacute;':'Y', '':'Y',
'à':'a', '<\\\#136>':'a', '&agrave;':'a', '':'a',
'á':'a', '<\\\#135>':'a', '&aacute;':'a', '':'a',
'â':'a', '<\\\#137>':'a', '&acirc;' :'a', '':'a',
'ã':'a', '<\\\#139>':'a', '&atilde;':'a', '':'a',
'ä':'a', '<\\\#138>':'a', '&auml;' :'a', '':'a',
'å':'a', '<\\\#140>':'a', '&aring;' :'a', '':'a',
'ç':'c', '<\\\#141>':'c', '&ccedil;':'c', '':'c',
'è':'e', '<\\\#143>':'e', '&egrave;':'e', '':'e',
'é':'e', '<\\\#142>':'e', '&eacute;':'e', '':'e',
'ê':'e', '<\\\#144>':'e', '&ecirc;' :'e', '':'e',
'ë':'e', '<\\\#145>':'e', '&euml;' :'e', '':'e',
'ì':'i', '<\\\#147>':'i', '&igrave;':'i', '':'i',
'í':'i', '<\\\#146>':'i', '&iacute;':'i', '':'i',
'î':'i', '<\\\#148>':'i', '&icirc;' :'i', '':'i',
'ï':'i', '<\\\#149>':'i', '&iuml;' :'i', '':'i',
'ñ':'n', '<\\\#150>':'n', '&ntilde;':'n', '':'n',
'ò':'o', '<\\\#152>':'o', '&ograve;':'o', '':'o',
'ó':'o', '<\\\#151>':'o', '&oacute;':'o', '':'o',
'ô':'o', '<\\\#153>':'o', '&ocirc;' :'o', '':'o',
'õ':'o', '<\\\#155>':'o', '&otilde;':'o', '':'o',
'ö':'o', '<\\\#154>':'o', '&ouml;' :'o', '':'o',
'ø':'o', '<\\\#191>':'o', '&oslash;':'o', '':'o',
'ù':'u', '<\\\#157>':'u', '&ugrave;':'u', '':'u',
'ú':'u', '<\\\#156>':'u', '&uacute;':'u', '':'u',
'û':'u', '<\\\#158>':'u', '&ucirc;' :'u', '':'u',
'ü':'u', '<\\\#159>':'u', '&uuml;' :'u', '':'u',
'ý':'y', '&yacute;':'y', '':'y',
'ÿ':'y', '<\\\#216>':'y', '&yuml;' :'y', '':'y'}

entitydefs = {
'quot':'"',
'amp':'&',
'apos':''',
'lt':'<',
'gt':'>',
'Agrave':'À',
'Aacute':'Á',
'Acirc':'Â',
'Atilde':'Ã',
'Auml':'Ä',
'Aring':'Å',
'Ccedil':'Ç',
'Egrave':'È',
'Eacute':'É',
'Ecirc':'Ê',
'Euml':'Ë',
'Igrave':'Ì',
'Iacute':'Í',
'Icirc':'Î',
'Iuml':'Ï',
'Ntilde':'Ñ',
'Ograve':'Ò',
'Oacute':'Ó',
'Ocirc':'Ô',
'Otilde':'Õ',
'Ouml':'Ö',
'Oslash':'Ø',
'Ugrave':'Ù',
'Uacute':'Ú',
'Ucirc':'Û',
'Uuml':'Ü',
'Yacute':'Ý',
'agrave':'à',
'aacute':'á',
'acirc':'â',
'atilde':'ã',
'auml':'ä',
'aring':'å',
'ccedil':'ç',
'egrave':'è',
'eacute':'é',
'ecirc':'ê',
'euml':'ë',
'igrave':'ì',
'iacute':'í',
'icirc':'î',
'iuml':'ï',
'ntilde':'ñ',
'ograve':'ò',
'oacute':'ó',
'ocirc':'ô',
'otilde':'õ',
'ouml':'ö',
'oslash':'ø',
'ugrave':'ù',
'uacute':'ú',
'ucirc':'û',
'uuml':'ü',
'yacute':'ý',
'yuml':'ÿ',
}

entitydefs2 = {
'quot':'<\#34>',
'amp':'<\#38>',
'apos':'<\#39>',
'lt':'<\#60>',
'gt':'<\#62>',
'Agrave':'<\#192>',
'Aacute':'<\#193>',
'Acirc':'<\#194>',
'Atilde':'<\#195>',
'Auml':'<\#196>',
'Aring':'<\#197>',
'Ccedil':'<\#199>',
'Egrave':'<\#200>',
'Eacute':'<\#201>',
'Ecirc':'<\#202>',
'Euml':'<\#203>',
'Igrave':'<\#204>',
'Iacute':'<\#205>',
'Icirc':'<\#206>',
'Iuml':'<\#207>',
'Ntilde':'<\#209>',
'Ograve':'<\#210>',
'Oacute':'<\#211>',
'Ocirc':'<\#212>',
'Otilde':'<\#213>',
'Ouml':'<\#214>',
'Oslash':'<\#216>',
'Ugrave':'<\#217>',
'Uacute':'<\#218>',
'Ucirc':'<\#219>',
'Uuml':'<\#220>',
'Yacute':'<\#221>',
'agrave':'<\#224>',
'aacute':'<\#225>',
'acirc':'<\#226>',
'atilde':'<\#227>',
'auml':'<\#228>',
'aring':'<\#229>',
'ccedil':'<\#231>',
'egrave':'<\#232>',
'eacute':'<\#233>',
'ecirc':'<\#234>',
'euml':'<\#235>',
'igrave':'<\#236>',
'iacute':'<\#237>',
'icirc':'<\#238>',
'iuml':'<\#239>',
'ntilde':'<\#241>',
'ograve':'<\#242>',
'oacute':'<\#243>',
'ocirc':'<\#244>',
'otilde':'<\#245>',
'ouml':'<\#246>',
'oslash':'<\#248>',
'ugrave':'<\#249>',
'uacute':'<\#250>',
'ucirc':'<\#251>',
'uuml':'<\#252>',
'yacute':'<\#253>',
'yuml':'<\#255>',
}
Jul 18 '05 #1
2 4482

ahsan> "__main__:1: DeprecationWarning: Non-ASCII character '\xc0' in file
ahsan> trans.py on line 11, but no encoding declared; see
ahsan> http://www.python.org/peps/pep-0263.html for details"

ahsan> I am not sure what encoding to use. I am not sure where to look. I
ahsan> picked one out of the documentation. Here is what I used:
ahsan> # -*- coding: utf-8 -*-

Looks like the data you posted was encoded as iso-8859-1 (aka, latin-1), so
I suggest you use:

# -*- coding: iso-8859-1 -*-

as your coding comment.

ahsan> Questions:
ahsan> 1) Is there a list I can pick the encoding from?

Look at the filenames in the encodings package (part of the standard
distribution).

ahsan> 2) How can I find more about encoding?

Pick and choose from the results in found in these googlings:

http://www.google.com/search?q=encod...www.python.org
http://www.google.com/search?q=unico...www.python.org

Skip

Jul 18 '05 #2
ahsan Imam wrote:
I am not sure what encoding to use. I am not sure where to look. I
picked one out of the documentation.
I recommend you avoid using non-ASCII characters in source code in
this specific case.
'À':'A', '<\\\#203>':'A', '&Agrave;':'A', '':'A',


Here, is a non-ASCII character. If you copy-and-past this
to a Python session, and do
ord("")

192

you find that it really is the character with the byte value
192. So reformulate the line above to

'À':'A', '<\\\#203>':'A', '&Agrave;':'A', chr(192):'A',

If you change all lines in this respect, you won't need an
encoding declaration anymore, as your source code is plain ASCII.

Regards,
Martin

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Pierre Rouleau | last post by:
Hi all! I am using Python 2.3.1 on Win32 (NT, 2000). Whenever a file imports the standard tempfile module, Python 2.3.1 issues the following warning: C:\Python23\lib\fcntl.py:7:...
0
by: Ben Finney | last post by:
Howdy all, I'm using a library that uses SmartCookie. In Python 2.3, that gives this warning: /usr/lib/python2.3/Cookie.py:712: DeprecationWarning: Cookie/SmartCookie class is insecure; do...
77
by: Gerrit Holl | last post by:
Hi, the <> inequality test operator has been deprecated for a loooooong time. Is there a reason that it doesn't trigger a DeprecationWarning? $ python2.2 -Wall -c "print 0 <> 0" 0 $...
5
by: Dan Jacobson | last post by:
Here's the deal: I have to maintain this long gone guy's programs and lately they've been saying ../north_pass.py:14: DeprecationWarning: integer argument expected, got float...
7
by: John Nagle | last post by:
How do I suppress "DeprecationWarning: Old style callback, use cb_func(ok, store) instead". A library is triggering this message, the library is being fixed, but I need to make the message...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.