Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
Hi all,

I recently created an telnet client for iOS.
With a few minor changes I made it for OSX.

However, I'm receiving this kind of replies:
ÿûÿþ"ÿþÿýÿýÿýÿûÿþ"ÿþÿýÿýÿý

Instead of normal text.

how do I find out what encoding I need to use?
(Running freesshd on a windows server)

Using the following:
Code:
while ([inputStream hasBytesAvailable]) {
  streamOutput = nil;
  len = [inputStream read:buffer maxLength:sizeof(buffer)];
  if (len > 0) {
    for(int a=1; a<30; a++) {
      NSString * serverSaid = [[NSString alloc] initWithBytes:buffer length:len encoding: a];
      NSLog(@"Server: %@", serverSaid);
    }
  }
}
I only receive stuff like:
Code:
2015-08-12 12:35:40.265 TerminalX[5997:348189] Server: ÿûÿþ"ÿþ
2015-08-12 12:35:40.265 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.271 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.271 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.271 TerminalX[5997:348189] Server: ÿûÿþ"ÿþ
2015-08-12 12:35:40.276 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.276 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.276 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.281 TerminalX[5997:348189] Server: ˙ű˙ţ"˙ţ
2015-08-12 12:35:40.281 TerminalX[5997:348189] Server: ǿ︢￾ÿﴃ�᣿ﴟ
2015-08-12 12:35:40.286 TerminalX[5997:348189] Server: яыяю"яю
2015-08-12 12:35:40.287 TerminalX[5997:348189] Server: ÿûÿþ"ÿþ
2015-08-12 12:35:40.291 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.296 TerminalX[5997:348189] Server: ÿûÿş"ÿş
2015-08-12 12:35:40.296 TerminalX[5997:348189] Server: ˙ű˙ţ"˙ţ
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: ÿûÿþ"ÿþ
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: (null)
2015-08-12 12:35:40.297 TerminalX[5997:348189] Server: (null)
 
Last edited:
how do I find out what encoding I need to use?

There is RFC2066 but I don't know how widely implemented it is and if it was ever ratified. I don't expect there to be many updates to telnet any time soon... Your only other option is to ask the user with a default of something sensible - normally that would be UTF-8 but if you are talking to things that still us telnet maybe its ASCII.

Are you sure you are only having encoding problems though? I would try a) doing a packet capture and see what is actually being sent and received and b) try a different telnet server and see if the behaviour is any different.
 
Thanks cqexbesd, I think that there is something with the freesshd server indeed.
I now installed bitvise ssh server, but this will need ssh client.
From terminal, ofcourse its no problem.

Doing some small research and I got libssh2 to compile and include in my project.
Together with some small examples I got it to work, however I now seem to struggle with ANSI code.
How can I use ANSI in a NSTextView?
I mean.. how do I parse this?
 
Last edited:
How can I use ANSI in a NSTextView?
I mean.. how do I parse this?

I don't know but I would be surprised if NSTextView had any ANSI support built in. Maybe someone has already written something and released it open source but I suspect you will have to parse the character stream and map escape sequences to the appropriate API calls yourself.
 
Since this was a Windows machine, chances are that it's either MS specific extended ascii or UTF16. Since all characters are messed up however, I world guess on UTF16, because even with extended ascii you world get sensible text out of the ascii range. The "beauty" of UTF16 is that there are three encodings available, little and big endian, plus a bastard fixed size MS specific version. Perhaps you can check on the Windows machine or just by trial and error on your end.
 
I don't recall the details, but way back in the day of using VT terminals and emulators I recall seeing such odd characters when the terminal was not setup quite right to the server. Can't remember if it was 8 bit versus 7 bit coding or something else. I'd look up a manual for a VT terminal an do a little digging on syncing of settings.
 
However, I'm receiving this kind of replies:
ÿûÿþ"ÿþÿýÿýÿýÿûÿþ"ÿþÿýÿýÿý

BTW you don't say if you have already dealt with option negotiation...not sure what happens if you just assume everything sent is text. Probably not the issue though.
 
BTW you don't say if you have already dealt with option negotiation...not sure what happens if you just assume everything sent is text. Probably not the issue though.
I think this thread has turned into the following one, by the same user:
https://forums.macrumors.com/threads/cocoa-nstextview-and-terminal-escape-sequences.1907661/

The linked thread provides some additional detail. It also seems that the "many kinds of accented y's, with occasional thorns" has become a different beast.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.