2

I programmed a telnet server using C as programming language but I have a problem to send characters with emphases (é, è, à ...). The character encoding is different between the telnet clients (windows, linux, putty, ...).

What can I do to detect the character encoding of the clients which are connected to my server ?

2 Answers 2

5

Guessing the encoding of a message based on its byte values is always imperfect, although it can be made to give relatively accurate results. There are libraries available to do this, e.g. IBM's ICU.

But the preferable option is always either to standardize client and server on one encoding and always use that, or to force the client to declare the encoding of messages explicitly. It requires only a little programming effort and solves the entire question once and for all.

2
  • My server must be compatible with all clients : I can't impose to the clients to send a message with a special message. It isn't possible with telnet option mecanisms to know the client character enconding ?
    – ipStack
    Commented Jan 15, 2015 at 13:25
  • 1
    en.wikipedia.org/wiki/Telnet#cite_note-3: "There was an attempt to introduce a switchable character encoding support like HTTP has, but nothing is known about its actual software support." You're stuck with guessing the best-fitting encoding, than. Commented Jan 15, 2015 at 13:29
2

You are pretty much stuck which something hokey like sending:

Which character looks like e with an acute accent:
1 -> è, 2 -> ò, 3 -> õ, 4 -> é, 5 -> none of these
enter choce 1-5: 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.