Unicode Support

Unicode support deals with the handling of special characters such as German umlauts ö, ä, French accents è, â etc. in script files. When you type one of these characters into Automa's interactive console, things should "just work". However, when you are writing your own .at scripts with an external editor or are using Automa as a Python library, some caution is required.

Special characters in .at files

If you want to include special characters in an Automa script, you need to save it using the UTF-8 encoding and place the following line at the top of the file:

# -*- coding: utf-8 -*-

For example, say you want to include the command click("Österreich") in your script (Österreich is "Austria" in German). If you simply run your script with Automa, you will likely get an error of the form:

UnicodeDecodeError('ascii', 'click("\xd6sterreich")', 7, 8, 'ordinal not
in range(128)')

To fix this problem, you need to add the above line to the top of your script, so it looks like the following:

# -*- coding: utf-8 -*-

Then, you need to save your file using the UTF-8 encoding. All current editors support this; here is an example screenshot of how to select the encoding in Notepad:

Selecting the UTF-8 encoding in Notepad

And that's it! When making future edits to your file, please ensure that your editor keeps the UTF-8 encoding and does not accidentally change it.

Special characters when using Automa as a Python library

When using Automa as a Python library, the same rules as above apply: If you wish to include special characters in your scripts, you need to specify the encoding using a comment line in the first line of the script and save your files using that encoding. Moreover, all strings with special characters need to be unicode strings u'...' in order to be usable with Automa's API functions. The former requirement of the # -*- coding: ... line actually comes from Python; Please see the section below for further references on this subject.

Further information

Our blog article New version of Automa with improved Unicode support gives a brief introduction to Unicode and explains interesting details and subtleties of Automa's and Python's Unicode implementations. We recommend this blog post as the first starting point. A good reference, particularly when using Automa as a Python library, is also the standard Python documentation on the subject.