How do I get my non-ascii characters in item labels to behave?

Hi,

I live in Sweden and I am having a bit of an issue with item labels and getting them to be encoded correctly all the way. I try to illustrate the issue (using the Safari browser, but i think the issue is present also in chrome - I have seen similar things happening, but I just have not investigated it to the same extent).

Ok,I may have a label like this, with some characters garbled. They were of course entered in from the PaperUI on the same browser.

Now, I may then edit the item so it looks like it should

and save and now the item looks ok. And, it will look ok also when exported to HomeKit (I just noticed) so everything seems fine now.

Ok, but eventually I may have to do something with the item (som edit, add it to a new group, whatever), and then the label is garbled again…

So, I would like to know if there is some way - like a strategy, setup or something else - that would allow my item labels to work well with the system.

  • Platform information:
    • Hardware: Rasberry pi 3
    • OS: Raspbian stretch + OSX 10.13.6
    • openHAB version: 2.3.0


Set to your value.

Yes, that seems to be the issue. It was set to ISO 8859-1 Swedish and not UTF8 (and perhaps I had not set it to Swedish at all, I cannot be sure). Anyway, it seems to work now. Thanks!

Sorry, but I need to re-open this thread, as I am now in a situation that is related to this change.

I set my locale to sv_SE.UTF-8 using the openhabian config tool and everything seemed fine. Now (perhaps after the first reboot, perhaps second - I don’t remember) I am getting these messages on most commands on the ssh console

-bash: warning: setlocale: LC_ALL: cannot change locale (sv_SE)
-bash: warning: setlocale: LC_ALL: cannot change locale (sv_SE)
-bash: warning: setlocale: LC_ALL: cannot change locale (sv_SE)
-bash: warning: setlocale: LC_ALL: cannot change locale (sv_SE)

and I not of course getting the correct characters any more.

I have tried re-generating locales, setting sv_SE again and then rebooting - does not change the issue. Any ideas on what I should try?

Maybe you should also remove the “[SOLVED]” tag from your title, this will keep people away from this conversation. :slight_smile:

Yes, it was added by the checkmark thing I guess. Removed it now. Thanks.

It seems that the issue may be a faulty LC_TYPE set somewhere. If I try to generate the locale manually

$ sudo locale-gen sv_SE.UTF-8
Generating locales (this might take a while)...
  de_DE.UTF-8... done
  en_GB.UTF-8... done
  en_US.UTF-8... done
  sv_SE.UTF-8... done
Generation complete.

i get this error message:

$ sudo update-locale sv_SE.UTF-8
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "sv_SE",
	LC_ALL = "sv_SE",
	LC_CTYPE = "sv_SE",
	LANG = "sv_SE.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("sv_SE.UTF-8").
*** update-locale: Error: invalid locale settings:  LC_CTYPE=sv_SE LC_ALL=sv_SE LANGUAGE=sv_SE

I cant see that I am setting LC_TYPE somewhere locally for the user

$ grep LC .bashrc .bash
.bash_history  .bash_logout   .bash_profile  .bashrc        
$ grep LC .bashrc .bash_profile 
$ grep LC .profile                   
$ grep LC .bashrc

Does anyone know where this setting comes from?

Syntax for update-locale is like this:

sudo update-locale LANG=sv_SE.UTF-8 LC_CTYPE=sv_SE.UTF-8 LANGUAGE=sv_SE.UTF-8 LC_ALL=sv_SE.UTF-8

Can you check whats getting set on you system? Mine looks good after above command.

openhabian@openHABianPi:~$ cat /etc/default/locale
#  File generated by update-locale
LANG=sv_SE.UTF-8
LC_CTYPE=sv_SE.UTF-8
LANGUAGE=sv_SE.UTF-8
LC_ALL=sv_SE.UTF-8

Yes, I got this to work now. Somehow. The issue “I think” may have been related to my having set sv_SE first (latin1) and then wanted to switch to sv_SE. I don’t know, whatever I did it never switched from sv_SE in /etc/default/locale and so on. It was never regenerated, even though it says that it did.

But, I was able to switch to the UTF-8 encoding version by making sure that I have latin 1 sv_SE and sv_SE.UTF-8 locale generated,manually editing the /etc/default/locale manually, rebooting and THEN go into openhabian-config and select and generate the locales again, and then rebooting again.
Not sure why and what was forced to be re-generated by this procedure, but it seems to work now.

No I just wish that there was an easy way to change all the erroneous characters in things’ and items’ labels…