Archived Forum Post

Index of archived forum posts


Socket with german vowl (äöüß) in C++/MFC

Jul 18 '13 at 10:00

Hello, i started to implement a socket which i do check for received data in a thread. Works as desired, but....i can not get the german vowl (umlauts) to work. I did try socket.put_Utf8(); but with no effective change.I receive crytical letters...


See this: Socket Programming "Must Know" Concepts

(from the web page at the above URL)

5. Sending and Receiving Strings

Let’s say you want to send the string “ABC” to the connected peer. Most programmers implicitly assume it means sending three bytes: 0×41, 0×42, and 0×43. This is usually correct, but the assumption was made that the communicating programs have pre-agreed upon using the ANSI charset (such as Windows-1252) such that “A” is represented by a single byte having the value 0×41, and “B” is represented by 0×42, etc. What if the sender sends ANSI but the receiver is expecting Unicode (utf-16). The receiver would be expecting 6 bytes because “A” is represented by 2 bytes (0×41, 0×00), “B” is represented by 0×42, 0×00, and so on..

The StringCharset property controls how strings are sent and received. It defaults to “ANSI”. If, for example, it is set to “Unicode”, then a call to SendString(”ABC”) would result in the sending of 6 bytes: 0×41, 0×00, 0×42, 0×00, 0×43, 0×00. The ReceiveString method would know to interpret the incoming bytes as 2-byte/char Unicode chars and correctly return the string “ABC” to the caller.

This is even more crucial when sending non-English characters, where there are many more choices for character encodings. For example, Japanese strings might be sent in Shift_JIS, iso-2022-jp, utf-8, Unicode (ucs-2), euc-jp, etc. It is important that the communicating peers agree on the byte representation of the strings sent and received.



i tested my winsock.exe which is waiting for a Connection with Telnet and other Clients (e.g. Works good with chars like äöü. I did try to get this to work with chilkat-socket like this


CString val ="cd ölf";

success = socket.SendString(val);

I did send a chcp 1252 as the first command so it Shows correctly in my Editcontrol with Foldername "ölf".

But a "cd ölf" gives:

C:> cd lf

Das System kann den angegebenen Pfad nicht finden.

The System is unable to find the path 'lf' with should have been 'ölf'