From 88f9b0f3b8be249ec26adefc0f93d2c03717878f Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Fri, 18 Feb 2022 19:18:57 +0000 Subject: [PATCH] fhem.pl: shutdown restart on encoding change git-svn-id: https://svn.fhem.de/fhem/trunk@25704 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/01_FHEMWEB.pm | 1 + fhem/docs/commandref_frame.html | 8 ++++++-- fhem/docs/commandref_frame_DE.html | 8 ++++++-- fhem/fhem.pl | 10 ++++++++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm index 4a2cd4860..01fe1f733 100644 --- a/fhem/FHEM/01_FHEMWEB.pm +++ b/fhem/FHEM/01_FHEMWEB.pm @@ -1280,6 +1280,7 @@ FW_digestCgi($) next if($pv eq ""); # happens when post forgot to set FW_ME $pv =~ s/\+/ /g; $pv =~ s/%([\dA-F][\dA-F])/chr(hex($1))/ige; + $pv = Encode::decode('UTF-8', $pv) if($unicodeEncoding); my ($p,$v) = split("=",$pv, 2); $v = "" if(!defined($v)); diff --git a/fhem/docs/commandref_frame.html b/fhem/docs/commandref_frame.html index 5bc26c7d6..369ad4837 100644 --- a/fhem/docs/commandref_frame.html +++ b/fhem/docs/commandref_frame.html @@ -1609,8 +1609,12 @@ The following local attributes are used by a wider range of devices:
  • encoding
    Set the internal encoding used for storing strings. Possible values: bytestream (default) and unicode.
    - Note: Since not all modules were checked, if they work correctly with - the internal unicode encoding, this feature is experimental. + Notes: +

  • diff --git a/fhem/docs/commandref_frame_DE.html b/fhem/docs/commandref_frame_DE.html index 34470fb9d..7dff88a89 100644 --- a/fhem/docs/commandref_frame_DE.html +++ b/fhem/docs/commandref_frame_DE.html @@ -1714,8 +1714,12 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
  • encoding
    Wählt das perl-interne Format, mit dem Strings kodiert sind. Mögliche Werte sind: bytestream (Voreinstellung) und unicode.
    - Achtung: der Wert unicode ist experimentell, da nicht alle FHEM-Module - mit dieser Variante geprüft wurden. + Achtung: +

  • diff --git a/fhem/fhem.pl b/fhem/fhem.pl index e4cb5e73c..7cec95656 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -2877,11 +2877,10 @@ GlobalAttr($$$$) my ($type, $me, $name, $val) = @_; if($type eq "del") { - my %noDel = ( modpath=>1, verbose=>1, logfile=>1, configfile=>1 ); + my %noDel = ( modpath=>1, verbose=>1, logfile=>1, configfile=>1, encoding=>1 ); return "The global attribute $name cannot be deleted" if($noDel{$name}); $featurelevel = 6.1 if($name eq "featurelevel"); $haveInet6 = 0 if($name eq "useInet6"); # IPv6 - $unicodeEncoding = undef if($name eq "encoding"); delete($defs{global}{ignoreRegexpObj}) if($name eq "ignoreRegexp"); return undef; } @@ -2904,6 +2903,13 @@ GlobalAttr($$$$) if($name eq "encoding") { # Should be called from fhem.cfg/configDB return "bad encoding parameter $val, good values are bytestream or unicode" if($val ne "unicode" && $val ne "bytestream"); + if($init_done) { + InternalTimer(0, sub { + CommandSave(undef, undef); + CommandShutdown(undef, "restart"); + }, undef); + return; + } $unicodeEncoding = ($val eq "unicode"); $currlogfile = ""; }