Encoding problem solution on APT repo installation

Hello OH Community,
I am using OH2 atm and added some special unicode characters to my transform files, so that they will look pretty on my sitemap. Unfortunatly I had some problems with APT installed version from the repository, It could’nt read the unicode symbols properly. The tar.gz archive version runs well with unicode symbols (ofc same OH release).

I figured out what the actual difference is in both versions: It’s the file encoding JVM property.
I started the archive version from command line and because Im using a unicode locale (en_US.UTF-8) the encoding gets passed to the JVM. On systemd service unit the terminal locale doesn’t matter.

Here are some examples:

To achieve proper unicode loading, just set
in file /etc/default/openhab2

Config files are ofc with proper file encoding converted.

Hope this helps someone :slight_smile:



After updating to 2.2 stable I ran into this issue again.
I put this parameter into the openhab2/runtime/bin/setenv file on following line

EXTRA_JAVA_OPTS_COMMON="-Djava.awt.headless=true -Dfile.encoding=UTF-8"

and it works as expected for me.
Now I want to make a PR on github but can’t find this file in openhab-distro/openhab-core (ESH?) repository.

Now two questions:

  1. Is the setenv file and line the proper place for this property?
  2. In which repository do I have to submit my PR?

Thanks in advance :slight_smile:

If it’s correct that each file should be treated with UTF-8 encoding regardless of operating system or implementation, then you’d be able to find the setenv parameter here (Unix/Mac) and here (Windows). If it’s safe to assume that any config file can be UTF-8 encoded, then please feel free to make a PR for others to review :slight_smile:

However, if this depends on the user’s specific setup, the best place to set it so that it does not get overwritten is in the /etc/default/openhab2 file as you mentioned in the first post.

Thanks for your tips and hints.
I have created a PR https://github.com/openhab/openhab-distro/pull/634

1 Like