I am trying to export a map using Python/ArcPy script. The problem that the title of the exported map containts somthing like "A(c)" instead of the accent "é" I wrote. The date (dt) is printed (in french) with no problem. This part of my scripts looks like:

    txt1="Densité  \n"+ dt

I am using Python 2.7, ArcGIS 10.2, Notepad++ as text editor and pythonWin IDE.

enter image description here

  • 2
    This looks like a codepage issue. Make sure the script uses UTF-8. – Vince Feb 14 at 11:34
  • Yes but I already tried to add this line in the top of my script: # -- coding: utf-8 -- – Mahfoud B. Feb 14 at 14:01
  • 1
    That might just be complicating matters, if The editor is writing something other than UTF-8. – Vince Feb 14 at 15:45
  • 1
    Try u"Densité \n". – fatih_dur Feb 15 at 1:08
  • @fatih_dur I tried to do that but it gives the eror: Rdmt_espece_date=u"Densit頠\n"+ dt UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 1: ordinal not in range(128) – Mahfoud B. Feb 17 at 8:46

The "é" characters that appeared in the exported map instead of the accented char "é" that I want, came from the change of the written script itself not in the way PythonWin compilate the code. I scripted my code using Notepad++ and the concerned part of the code was written like this:

Rtxt1="Densité  \n"+ dt

But when I tried to open th script and run it under PythonWin I found that it was changed to:

Rtxt1="Densité  \n"+ dt

So I changed it back to "é" in the PythonWin editor, run the script and it worked with no problem. I don't really know what exactly happen when going from Notepad++ to PythonWin but I think they don't treat accented chacters in the same way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.