Python, (Indigo) and Umlaute

Posted on
Sat Mar 28, 2020 9:43 am
davinci offline

Python, (Indigo) and Umlaute

Code: Select all
Automower= indigo.variables["Automower"].value
if Automower == "Mähen" :
    result = true
else:
    result = false


The variable is "Mähen".

Why is the result false?

I tried adding this at the top of the python file but still...
# -*- coding: utf-8 -*-

It works with this:
if Automower == u"Mähen" :

Is the problem on Indigo or on Python?

Posted on
Sat Mar 28, 2020 11:17 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Python, (Indigo) and Umlaute

In Python 2.X you need to explicitly identify a string as unicode, so your change was correct:

Code: Select all
Automower= indigo.variables["Automower"].value
if Automower == u"Mähen" :
    result = true
else:
    result = false

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Mar 28, 2020 1:57 pm
davinci offline

Re: Python, (Indigo) and Umlaute

Good to know, but weird...
Thanks.

Posted on
Sat Mar 28, 2020 2:08 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Python, (Indigo) and Umlaute

davinci wrote:
Good to know, but weird...


Why do you think it's weird? The original definition of the string type in Python was ASCII encoding. Unicode was added as a new type. Then in Python 3, the default for all strings was made Unicode, and if you wanted an "old style" string you needed to use the b"" notation.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests