2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

98_update.pm: support encoding unicode (Forum #126088)

git-svn-id: https://svn.fhem.de/fhem/trunk@25724 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2022-02-21 17:12:17 +00:00
parent 7345cc6c86
commit 31e063c253
2 changed files with 6 additions and 4 deletions

View File

@ -520,6 +520,7 @@ upd_getUrl($)
$url =~ s/%/%25/g;
$upd_connecthash{url} = $url;
$upd_connecthash{keepalive} = ($url =~ m/localUpdate/ ? 0 : 1); # Forum #49798
$upd_connecthash{forceEncoding} = "" if($unicodeEncoding);
my ($err, $data) = HttpUtils_BlockingGet(\%upd_connecthash);
if($err) {
uLog 1, $err;

View File

@ -976,9 +976,10 @@ HttpUtils_ParseAnswer($)
return ($@, $ret) if($@);
}
}
my $encoding = ($hash->{httpheader} =~ m/^Content-Type.*charset=(\S*)/im ?
$1 : 'UTF-8');
$ret = Encode::decode($encoding, $ret) if($unicodeEncoding);
my $encoding = defined($hash->{forceEncoding}) ? $hash->{forceEncoding} :
$hash->{httpheader} =~ m/^Content-Type.*charset=(\S*)/im ? $1 :
'UTF-8';
$ret = Encode::decode($encoding, $ret) if($unicodeEncoding && $encoding);
# Debug
Log3 $hash, $hash->{loglevel}+1,
@ -995,7 +996,7 @@ HttpUtils_ParseAnswer($)
# digest(0),hideurl(0),timeout(4),data(""),loglevel(4),header("" or HASH),
# noshutdown(1),shutdown(0),httpversion("1.0"),ignoreredirects(0)
# method($data?"POST":"GET"),keepalive(0),sslargs({}),user(),pwd()
# compress(1), incrementalTimeout(0)
# compress(1), incrementalTimeout(0), forceEncoding(undef)
# Example:
# { HttpUtils_NonblockingGet({ url=>"http://fhem.de/MAINTAINER.txt",
# callback=>sub($$$){ Log 1,"ERR:$_[1] DATA:".length($_[2]) } }) }