On Mar 16, 5:43 am, Baptiste Carvello <baptiste...@free.fr> wrote: > Joel Pendery a écrit :
> > So I am trying to write a bit of code and a simple numerical > > subtraction > > > y_diff = y_diff-H > > > is giving me the error > > > Syntaxerror: Non-ASCII character '\x96' in file on line 70, but no > > encoding declared. > > > I would say that when you press the minus key, your operating system doesn't > encode the standard (ASCII) minus character, but some fancy character, which > Python cannot interpret. The likelihood that any operating system however brain-damaged and in whatever locale would provide by default a "keyboard" or "input method" that generated EN DASH when the '-' key is struck is somewhere between zero and epsilon. Already advanced theories like "used a word processor instead of a programmer's editor" and "scraped it off the web" are much more plausible. > More precisely, I suspect you are unsing Windows with codepage 1252 (latin 1). Codepage 1252 is not "latin1" in the generally accepted meaning of "latin1" i.e. ISO-8859-1. It is a superset. MS in their wisdom or otherwise chose to use most of the otherwise absolutely wasted slots assigned to "C1 control characters" in latin1. > With this encoding, you have 2 kinds of minus signs: the standard (45th > character, in hex '\x2d') and the non-standard (150th character, in hex > '\x96'). > > cf:http://msdn.microsoft.com/en-us/library/cc195054.aspx The above link quite correctly says that '\x96` maps to U+2013 EN DASH. EN DASH is not any kind of minus sign. Aside: the syndrome causing the problem is apparent with cp125x for x in range(9) -- http://mail.python.org/mailman/listinfo/python-list