Add UTF-8 encoding for reading bulk updates
This commit introduces the use of the `Encode` module to ensure that values being processed in the `WriteReadings` subroutine are correctly encoded in UTF-8. The previous implementation did not account for potential non-UTF-8 encoded data which could lead to issues when updating readings. The change specifically checks if the value (`$v`) is marked as UTF-8 using `Encode::is_utf8()`. If it is, the value is re-encoded to UTF-8 before being passed to `::readingsBulkUpdate()`. This adjustment ensures that all data written to readings maintains proper character encoding, improving compatibility and preventing potential data corruption. No breaking changes are introduced, but it is important for users to validate that their readings correctly display any special characters post-update.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
UPD 2025-10-14_10:40:53 10358 FHEM/73_NUKIBridge.pm
|
||||
UPD 2025-10-14_10:41:09 11100 FHEM/74_NUKIDevice.pm
|
||||
UPD 2025-10-14_10:42:11 42820 lib/FHEM/Devices/Nuki/Bridge.pm
|
||||
UPD 2025-10-14_10:42:04 16698 lib/FHEM/Devices/Nuki/Device.pm
|
||||
UPD 2025-10-14_11:00:54 10358 FHEM/73_NUKIBridge.pm
|
||||
UPD 2025-10-14_11:00:54 11100 FHEM/74_NUKIDevice.pm
|
||||
UPD 2025-10-14_11:00:54 42820 lib/FHEM/Devices/Nuki/Bridge.pm
|
||||
UPD 2025-10-15_06:43:51 16775 lib/FHEM/Devices/Nuki/Device.pm
|
||||
|
@@ -30,7 +30,7 @@ use strict;
|
||||
use warnings;
|
||||
|
||||
#use experimental qw( switch );
|
||||
|
||||
use Encode;
|
||||
use FHEM::Meta;
|
||||
|
||||
use GPUtils qw(GP_Import);
|
||||
@@ -550,7 +550,8 @@ sub WriteReadings {
|
||||
while ( ( $t, $v ) = each %{$decode_json} ) {
|
||||
|
||||
# generische readings (alles außer spezielle Felder)
|
||||
::readingsBulkUpdate( $hash, $t, $v )
|
||||
::readingsBulkUpdate( $hash, $t,
|
||||
Encode::is_utf8($v) ? Encode::encode( "UTF-8", $v ) : $v )
|
||||
if ( $t ne 'state'
|
||||
&& $t ne 'mode'
|
||||
&& $t ne 'deviceType'
|
||||
|
Reference in New Issue
Block a user