From 706b2dca586c855664020e293fc276b52f046a59 Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Tue, 6 Aug 2013 09:15:31 +0000 Subject: [PATCH] utf8ToLatin1 added git-svn-id: https://svn.fhem.de/fhem/trunk@3599 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/fhem.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fhem/fhem.pl b/fhem/fhem.pl index a160fb0d0..59a221a60 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -3421,13 +3421,21 @@ computeClientArray($$) return \@a; } +# http://perldoc.perl.org/perluniintro.html, UNICODE IN OLDER PERLS sub latin1ToUtf8($) { - # http://perldoc.perl.org/perluniintro.html, UNICODE IN OLDER PERLS my ($s)= @_; $s =~ s/([\x80-\xFF])/chr(0xC0|ord($1)>>6).chr(0x80|ord($1)&0x3F)/eg; return $s; } +sub +utf8ToLatin1($) +{ + my ($s)= @_; + $s =~ s/([\xC2\xC3])([\x80-\xBF])/chr(ord($1)<<6&0xC0|ord($2)&0x3F)/eg; + return $s; +} + 1;