Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through
Buy Me a Coffee or
Ko-fi . Thank you for helping preserve the EventGhost community.
If you have a question or need help, this is the place to be.
Mastiff
Experienced User
Posts: 872 Joined: Thu May 03, 2012 10:43 am
Post
by Mastiff » Mon Jan 18, 2016 11:03 am
I know the correct way of printing unicode strings:
But how do I print unicode variables? So:
Code: Select all
testvariable='├©├ª├Ñ'
print(testvariable)
This gives me:
So how do I use the unicode marker with variables?
Pako
Plugin Developer
Posts: 2294 Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:
Post
by Pako » Mon Jan 18, 2016 1:09 pm
Properly it should be as follows:
Code: Select all
testvariable = u'├©├ª├Ñ'
print testvariableIf the variable is not a unicode string, then it could be like this:
Code: Select all
print testvariable.decode(eg.systemEncoding)Pako
Mastiff
Experienced User
Posts: 872 Joined: Thu May 03, 2012 10:43 am
Post
by Mastiff » Mon Jan 18, 2016 1:20 pm
Thanks, Pako, but I'm afraid that doesn't work. I have my zones like this:
Code: Select all
eg.globals.Rom[1] = 'WC'
eg.globals.Rom[2] = 'Garderoberom'
eg.globals.Rom[3] = 'Midtsoverom'
eg.globals.Rom[4] = 'Hj├©rnesoverom'
eg.globals.Rom[5] = 'Hovedsoverom'
eg.globals.Rom[6] = 'Bad'
eg.globals.Rom[7] = 'Stue'
eg.globals.Rom[8] = 'Kj├©kken'
eg.globals.Rom[9] = 'Kino'
eg.globals.Rom[10] = 'Biljardrom'
eg.globals.Rom[11] = 'Kjellerkontor'
eg.globals.Rom[12] = 'Treningsrom'
eg.globals.Rom[13] = 'Gjesterom'
And if I try this:
Code: Select all
print eg.globals.Rom[8].decode(eg.systemEncoding)
I get this:
So what I need is a way to get this to show "kj├©kken" instead. I use it amongst other things in this print statement:
Code: Select all
print '%s.: Temperatur: %s, termostattemperatur: %s, tidspunkt: %s\n'%((eg.globals.Rom[int(Rom)]),eg.globals.Romtemperatur[Rom],eg.globals.Termostatemperatur[Rom], eg.globals.Tid[Rom])
Here the
eg.globals.Rom[int(Rom)] is the variable that contains ├©. Is there a way to get that right?
Pako
Plugin Developer
Posts: 2294 Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:
Post
by Pako » Mon Jan 18, 2016 1:28 pm
Mastiff wrote: Is there a way to get that right?
Of course.
I wrote, correctly it should be as follows:
So your real variables should look like this:
Code: Select all
eg.globals.Rom[1] = u'WC'
eg.globals.Rom[2] = u'Garderoberom'
eg.globals.Rom[3] = u'Midtsoverom'
eg.globals.Rom[4] = u'Hj├©rnesoverom'
eg.globals.Rom[5] = u'Hovedsoverom'
eg.globals.Rom[6] = u'Bad'
eg.globals.Rom[7] = u'Stue'
eg.globals.Rom[8] = u'Kj├©kken'
eg.globals.Rom[9] = u'Kino'
eg.globals.Rom[10] = u'Biljardrom'
eg.globals.Rom[11] = u'Kjellerkontor'
eg.globals.Rom[12] = u'Treningsrom'
eg.globals.Rom[13] = u'Gjesterom'Pako
Mastiff
Experienced User
Posts: 872 Joined: Thu May 03, 2012 10:43 am
Post
by Mastiff » Mon Jan 18, 2016 1:34 pm
Aha, now I understand! I thought the u would be part of the variable! Silly me. Thanks a lot! That even fixed the problem I had with the webserver not eating these letters.