mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
98_telnet.pm: fix unicode for latin1 terminals (Forum #126088)
git-svn-id: https://svn.fhem.de/fhem/trunk@25698 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
66656119b0
commit
c82f77ee6a
@ -219,7 +219,10 @@ telnet_Read($)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$buf = Encode::decode('UTF-8', $buf) if($unicodeEncoding);
|
if($unicodeEncoding) {
|
||||||
|
my $enc = $hash->{encoding} eq "latin1" ? "Latin1" : "UTF-8";
|
||||||
|
$buf = Encode::decode($enc, $buf);
|
||||||
|
}
|
||||||
$hash->{BUF} .= $buf;
|
$hash->{BUF} .= $buf;
|
||||||
my @ret;
|
my @ret;
|
||||||
my $gotCmd;
|
my $gotCmd;
|
||||||
@ -255,7 +258,8 @@ telnet_Read($)
|
|||||||
$cmd = $hash->{prevlines} . $cmd;
|
$cmd = $hash->{prevlines} . $cmd;
|
||||||
undef($hash->{prevlines});
|
undef($hash->{prevlines});
|
||||||
}
|
}
|
||||||
$cmd = latin1ToUtf8($cmd) if( $hash->{encoding} eq "latin1" );
|
$cmd = latin1ToUtf8($cmd)
|
||||||
|
if(!$unicodeEncoding && $hash->{encoding} eq "latin1");
|
||||||
$ret = AnalyzeCommandChain($hash, $cmd);
|
$ret = AnalyzeCommandChain($hash, $cmd);
|
||||||
push @ret, $ret if(defined($ret));
|
push @ret, $ret if(defined($ret));
|
||||||
}
|
}
|
||||||
@ -297,14 +301,20 @@ telnet_Output($$$)
|
|||||||
my ($hash,$ret,$nonl) = @_;
|
my ($hash,$ret,$nonl) = @_;
|
||||||
|
|
||||||
if($ret && defined($hash->{CD})) {
|
if($ret && defined($hash->{CD})) {
|
||||||
$ret = utf8ToLatin1($ret) if( $hash->{encoding} eq "latin1" );
|
if($unicodeEncoding) {
|
||||||
|
$ret = Encode::encode($hash->{encoding} eq "latin1" ? "Latin1" : "UTF-8", $ret);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$ret = utf8ToLatin1($ret) if($hash->{encoding} eq "latin1");
|
||||||
|
$ret = Encode::encode('UTF-8', $ret)
|
||||||
|
if(utf8::is_utf8($ret) && $ret =~ m/[^\x00-\xFF]/);
|
||||||
|
}
|
||||||
|
|
||||||
if(!$nonl) { # AsyncOutput stuff
|
if(!$nonl) { # AsyncOutput stuff
|
||||||
$ret = "\n$ret\n$hash->{prompt} " if( $hash->{showPrompt});
|
$ret = "\n$ret\n$hash->{prompt} " if( $hash->{showPrompt});
|
||||||
$ret = "$ret\n" if(!$hash->{showPrompt});
|
$ret = "$ret\n" if(!$hash->{showPrompt});
|
||||||
}
|
}
|
||||||
for(;;) {
|
for(;;) {
|
||||||
$ret = Encode::encode('UTF-8', $ret) if($unicodeEncoding ||
|
|
||||||
utf8::is_utf8($ret) && $ret =~ m/[^\x00-\xFF]/);
|
|
||||||
my $l = syswrite($hash->{CD}, $ret);
|
my $l = syswrite($hash->{CD}, $ret);
|
||||||
last if(!$l || $l == length($ret));
|
last if(!$l || $l == length($ret));
|
||||||
$ret = substr($ret, $l);
|
$ret = substr($ret, $l);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user