Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8687023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:00:52+00:00 2026-06-12T23:00:52+00:00

I am sending data to a Socket and connection and retrieving some data. The

  • 0

I am sending data to a Socket and connection and retrieving some data. The data I am retrieving (which is an XML document) contains umlauts like ä,ü,ö,… but these are not correctly encoded, I only get ? or )))@ symbols instead of the umlaut.

Is there something incorrect how I retrieve the data ? The data is send back as ISO-8859-1 encoding.

My code:

public bool GetData()
    {
        try
        {
            TcpClient tcpClient = new TcpClient("THEIP", 5004);

            NetworkStream ns = tcpClient.GetStream();

            if (ns.CanWrite)
            {
                string text = this.xmlRequest;
                byte[] sendBytes = Encoding.ASCII.GetBytes(text);

                string sendData = Encoding.ASCII.GetString(sendBytes);

                ns.Write(sendBytes, 0, sendBytes.Length);
            }

            System.Threading.Thread.Sleep(2000);

            int i = 0;

            if (ns.CanRead)
            {
                do
                {

                    byte[] recvBytes = new byte[tcpClient.ReceiveBufferSize];

                    i = i + ns.Read(recvBytes, 0, tcpClient.ReceiveBufferSize);



                    string returnData = Encoding.ASCII.GetString(recvBytes);

                    returnData = returnData.Substring(0, i);

                    this.xmlResponse = returnData;

                } while (ns.DataAvailable);
            }

            // got full data...
            bool status = this.ProcessXMLData();
            ns.Close();

            if (status)
            {
                return true;
            }
            else
            {
                return false;
            }


        }
        catch (SocketException se)
        {
            this.errorFlag = true;
            this.errorMessage = se.Message;
            return false;
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:00:54+00:00Added an answer on June 12, 2026 at 11:00 pm

    If you are sure about the encode is being used is ISO-8859-1 then Instead of Encoding.ASCII use Encoding.GetEncoding("ISO-8859-1")

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using process-send-string to send data to a socket connection, but I'm not satisfied
I'm having trouble unencoding some data I get from a socket connection through messagepack,
When sending data from one iOS device to another, I receive these errors. 2012-06-21
I am sending data in database Like Hello fnds, How are you. I am
I got problem with sending data in Android using httpPost. I found some example,
There are plenty of examples of sending data to SugarCRM via a web-service, but
I have a socket server, written in C++ using boost::asio, and I'm sending data
My application is unable to transfer data properly over a socket connection and write
I am sending a fix message over socket connection and recieving within a python
I have an android application with a background thread that contains a socket connection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.