From 09f177490c4cbfdcf4ad517f45d3826c650fd025 Mon Sep 17 00:00:00 2001 From: jpawlowski Date: Sun, 27 Nov 2016 12:05:20 +0000 Subject: [PATCH] 59_Wunderground: fix UTF8 encoding git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@12669 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/59_Wunderground.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/FHEM/59_Wunderground.pm b/FHEM/59_Wunderground.pm index f36f57b02..8419eb21e 100644 --- a/FHEM/59_Wunderground.pm +++ b/FHEM/59_Wunderground.pm @@ -31,7 +31,8 @@ use strict; use warnings; use vars qw(%data); use HttpUtils; -use Encode; +use utf8; +use Encode qw(encode_utf8 decode_utf8); use Unit; use Data::Dumper; @@ -701,8 +702,13 @@ sub Wunderground_Hash2Readings($$;$) { } $reading = "fc" . $period . "_"; - $h->{fcttext_metric} =~ s/(\d)C/$1°C/g; - $h->{fcttext} =~ s/(\d)F/$1 °F/g; + my $symbol_c = Encode::encode_utf8( chr(0x202F) . chr(0x00B0) . 'C' ); + my $symbol_f = Encode::encode_utf8( chr(0x202F) . chr(0x00B0) . 'F' ); + my $symbol_pct = Encode::encode_utf8( chr(0x00A0) . '%' ); + $h->{fcttext_metric} =~ s/(\d)C/$1$symbol_c/g; + $h->{fcttext} =~ s/(\d)F/$1$symbol_f/g; + $h->{fcttext_metric} =~ s/(\d)\s*%/$1$symbol_pct/g; + $h->{fcttext} =~ s/(\d)\s*%/$1$symbol_pct/g; readingsBulkUpdate( $hash, $reading . "icon$night", $h->{icon} );