Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[automation] Use UTF-8 to read files #1484

Merged
merged 1 commit into from
May 20, 2020

Conversation

cweitkamp
Copy link
Contributor

  • Use UTF-8 to read files

Otherwise I am seeing e.g. such log messages:

2020-05-19 14:37:56.639 [INFO ] [ipse.smarthome.model.script.presence] - Trigger für presenceChristophPresent changed from OFF to ON ...

Or wrong tags:

        "tags": [
            "Anwesenheit",
            "Küche"
        ],

Signed-off-by: Christoph Weitkamp github@christophweitkamp.de

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
@cweitkamp cweitkamp added bug An unexpected problem or unintended behavior of the Core automation labels May 19, 2020
Copy link

@5iver 5iver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never noticed this. What script language were you using?

I have not tested it, but everything looks good to me. However, there is a lot more than just UTF-8 changes in there! 🙂

@cweitkamp
Copy link
Contributor Author

I am using Python combined with the helper libraries.

@5iver
Copy link

5iver commented May 20, 2020

Are you using unicode strings? I have a pile of updates for the helper libraries and one of them is using unicode for all of the core libraries.

@cweitkamp
Copy link
Contributor Author

automation/jsr223/python/personal/presence.py: Python script, UTF-8 Unicode text executable

Copy link
Member

@wborn wborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@wborn wborn merged commit 53a749f into openhab:master May 20, 2020
@cweitkamp cweitkamp deleted the bugfix-automation-charset branch May 20, 2020 20:36
@5iver
Copy link

5iver commented May 26, 2020

@cweitkamp, I have tested this and I did not see any difference in functionality. Do you have a before/after test to show that this change is doing something?

Edit... I took another peak. Wouldn't the Charset for InputStreamReader defaulted to UTF-8, so specifying it wouldn't actually be changing anything?

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/no-international-characters-unicode-with-jsr223-jython/99567/9

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/no-international-characters-unicode-with-jsr223-jython/99567/10

@cweitkamp
Copy link
Contributor Author

IIRC InputStreamReader defaults to system default charset - which might not always be UTF-8. Specifying it does not hurt as we try to keep it aligned throughout the framework.

I learned of this community post that OHC is not the real problem but encoding used by current Python / Jython version. For me masking a String via u"..." in my rules and saving the files with UTF-8 encoding is a working solution.

@wborn wborn added this to the 3.0 milestone Aug 26, 2020
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 11, 2023
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
GitOrigin-RevId: 53a749f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automation bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants