net-telnet icon indicating copy to clipboard operation
net-telnet copied to clipboard

cmd returns strings with different encodings in some cases

Open Xeitor opened this issue 11 months ago • 0 comments

Description

I am using the Net::Telnet gem to connect to remove servers, most of the times, the returned string by the cmd method has UTF-8 encoding, but the other day, one of the outputs from the server returned the character "ñ" and when the character is present in the output the encoding from the string is BINARY, I could not figure out where this change in the encoding is happening and why

Example:

client = Net::Telnet.new('Host' => "192.168.1.2", 'Port' => 23, 'Prompt' => //, 'Waittime' => 0.5, 'Timeout' => 30)

result_1 = client.cmd("test 1") # command does not return ñ
result_1.encoding -> #<Encoding:UTF-8>

result_2 = client.cmd("test 2") # command does return ñ
result_2.encoding -> #<Encoding:BINARY>

Version

ruby 3.2.0 net-telnet 0.2

Xeitor avatar Mar 15 '24 21:03 Xeitor