On Thu, Aug 14, 2014 at 9:21 AM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > YBM wrote: > >> Le 14/08/2014 16:04, marc.vanhoomis...@gmail.com a écrit : >>> Hello YBM, >>> I tried your suggestions, without improvement. >>> Further, see my answer to Vincent Vande Vyre >>> Thanks anyway. >> >> This is indeed very surprising. Are you sure that you >> have *exactly* this line at the first or second (not >> later !) line of your script : >> >> # -*- encoding: utf-8 -*- >> >> if a single caracter differs, it would fail. > > That's not correct. The encoding declaration is very flexible. Any of these > will be accepted: > > # This file uses the encoding: utf_8 > # coding=UTF-8 > # -*- coding: utf8 -*- > # vim: set fileencoding=utf-8 : > # Uses encoding:utf8 > # I want my encoding=UtF_8 okay! > #### textencoding= UTf-8 blah blah blah > > and many, many other varieties. The rules are: > > (1) It must be a comment; > > (2) It must be in the first or second line of the file; > > (3) It must match the regular expression r"coding[:=]\s*([-\w.]+)" > > > However, just because you declare the file to be UTF-8, doesn't mean it > *actually is* UTF-8. If your text editor is configured to use (say) > Latin-1, a UTF-8 encoding declaration will just give you garbage. > > * Fix your system to use UTF-8 by default. > > * Fix your editor to use UTF-8. > > * Add a UTF-8 encoding declaration. > > And then things should work.
And apart from all of that, if the OP is really using Python 3 then UTF-8 is the default source encoding anyway. -- https://mail.python.org/mailman/listinfo/python-list