2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

utf8ToLatin1 added

git-svn-id: https://svn.fhem.de/fhem/trunk@3599 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2013-08-06 09:15:31 +00:00
parent 4b093f189d
commit 19e1f858c3

View File

@ -3421,13 +3421,21 @@ computeClientArray($$)
return \@a; return \@a;
} }
# http://perldoc.perl.org/perluniintro.html, UNICODE IN OLDER PERLS
sub sub
latin1ToUtf8($) latin1ToUtf8($)
{ {
# http://perldoc.perl.org/perluniintro.html, UNICODE IN OLDER PERLS
my ($s)= @_; my ($s)= @_;
$s =~ s/([\x80-\xFF])/chr(0xC0|ord($1)>>6).chr(0x80|ord($1)&0x3F)/eg; $s =~ s/([\x80-\xFF])/chr(0xC0|ord($1)>>6).chr(0x80|ord($1)&0x3F)/eg;
return $s; return $s;
} }
sub
utf8ToLatin1($)
{
my ($s)= @_;
$s =~ s/([\xC2\xC3])([\x80-\xBF])/chr(ord($1)<<6&0xC0|ord($2)&0x3F)/eg;
return $s;
}
1; 1;