ruby / ruby/net-telnet

cmd returns strings with different encodings in some cases

Open
#34 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
57
Forks
36
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the encoding difference with the Net::Telnet#cmd examples in the issue, then trace where cmd receives and returns server output. Done means the behavior is understood and cmd returns a consistent, documented encoding for output containing non-ASCII characters.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.