mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
98_GAEBUS.pm: use utf-8 coding for values read from .csv files
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@9254 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
71a983530d
commit
02f8ab101a
@ -11,7 +11,7 @@
|
|||||||
# 11.09.2015 : A.Goebel : add set w~ commands to set attributes for writing
|
# 11.09.2015 : A.Goebel : add set w~ commands to set attributes for writing
|
||||||
# 11.09.2015 : A.Goebel : add set <write-reading> command to write to ebusd
|
# 11.09.2015 : A.Goebel : add set <write-reading> command to write to ebusd
|
||||||
# 13.09.2015 : A.Goebel : increase timeout for reads from ebusd from 1.8 to 5.0
|
# 13.09.2015 : A.Goebel : increase timeout for reads from ebusd from 1.8 to 5.0
|
||||||
# 13.09.2015 : A.Goebel : use html entities to display values from ".csv" files
|
# 14.09.2015 : A.Goebel : use utf-8 coding to display values from ".csv" files
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
|
|
||||||
@ -20,6 +20,7 @@ use warnings;
|
|||||||
use Time::HiRes qw(gettimeofday);
|
use Time::HiRes qw(gettimeofday);
|
||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
use IO::Select;
|
use IO::Select;
|
||||||
|
use Encode;
|
||||||
|
|
||||||
sub GAEBUS_Attr(@);
|
sub GAEBUS_Attr(@);
|
||||||
|
|
||||||
@ -182,6 +183,8 @@ GAEBUS_Set($@)
|
|||||||
|
|
||||||
#Log3 ($hash, 3, "ebus1: reopen $name");
|
#Log3 ($hash, 3, "ebus1: reopen $name");
|
||||||
|
|
||||||
|
#Log3 ($hash, 2, "$name: set $arg $type invalid parameter");
|
||||||
|
|
||||||
if ($type eq "reopen") {
|
if ($type eq "reopen") {
|
||||||
Log3 ($hash, 3, "ebus1: reopen");
|
Log3 ($hash, 3, "ebus1: reopen");
|
||||||
GAEBUS_CloseDev($hash);
|
GAEBUS_CloseDev($hash);
|
||||||
@ -608,7 +611,6 @@ GAEBUS_ProcessCSV($$)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
my $line;
|
my $line;
|
||||||
my $buffer = "";
|
my $buffer = "";
|
||||||
|
|
||||||
@ -619,28 +621,31 @@ GAEBUS_ProcessCSV($$)
|
|||||||
$defCircuit =~ s,^.*/,,;
|
$defCircuit =~ s,^.*/,,;
|
||||||
$defCircuit =~ s/\.csv$//;
|
$defCircuit =~ s/\.csv$//;
|
||||||
|
|
||||||
|
binmode(CSV, ':encoding(utf-8)');
|
||||||
while (<CSV>)
|
while (<CSV>)
|
||||||
{
|
{
|
||||||
next if /^#/;
|
next if /^#/;
|
||||||
next if /^\s$/;
|
next if /^\s$/;
|
||||||
s/\r//;
|
s/\r//;
|
||||||
|
|
||||||
s/ä/\ä/g;
|
#s/ä/\ä/g;
|
||||||
s/Ä/\Ä/g;
|
#s/Ä/\Ä/g;
|
||||||
s/ü/\ü/g;
|
#s/ü/\Ä/g;
|
||||||
s/Ü/\Ü/g;
|
#s/Ü/\Ü/g;
|
||||||
s/ö/\ö/g;
|
#s/ö/\ö/g;
|
||||||
s/Ö/\Ö/g;
|
#s/Ö/\Ö/g;
|
||||||
s/ß/\ß/g;
|
#s/ß/\ß/g;
|
||||||
#s/"/\"/g;
|
#s/"/\"/g;
|
||||||
|
|
||||||
chomp;
|
chomp;
|
||||||
|
|
||||||
$line = $_;
|
$line = encode("UTF-8", $_);
|
||||||
$line =~ s/ /_/g; # no blanks in names and comments
|
$line =~ s/ /_/g; # no blanks in names and comments
|
||||||
$line =~ s/$delimiter/_/g; # clean up the delimiter within the text
|
$line =~ s/$delimiter/_/g; # clean up the delimiter within the text
|
||||||
#$line =~ s/\|/_/g; # later used as delimiter in arguments
|
#$line =~ s/\|/_/g; # later used as delimiter in arguments
|
||||||
|
|
||||||
|
#Log3 ($hash, 2, "READ $file $line");
|
||||||
|
|
||||||
my ($io, $circuit, $vname, $comment, @params) = split (",", $line, 5);
|
my ($io, $circuit, $vname, $comment, @params) = split (",", $line, 5);
|
||||||
|
|
||||||
# handle defaults: "^*"
|
# handle defaults: "^*"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user