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 9092307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:48:39+00:00 2026-06-16T22:48:39+00:00

I have the following code, converted to C# from an old VB6 program. The

  • 0

I have the following code, converted to C# from an old VB6 program. The VB6 had used the old Winsock, which could accept a String argument, but the C# program uses System.Net.Socket which wants a byte array.

byte[] msg = Encoding.UTF8.GetBytes(tempString); 
_TCPConn.Send(msg);

tempString has

0x0002 (' ')
0x0000 ('\0')
0x0000 ('\0')
0x0000 ('\0')
0x0080 (' ')
0x006d ('m')
0x0068 ('h') 

But msg gets an extra byte

0x02 
0x00
0x00
0x00
**0xc2**
0x80
0x6d
0x68

Where is that “c2” coming from?

  • 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-16T22:48:40+00:00Added an answer on June 16, 2026 at 10:48 pm

    That is what UTF8 does. Values from 0x80 to 0x7FF get encoded with 2 bytes. Values from 0x800 to 0xFFFF get encoded with 3 bytes. 0xC2 0x80 tells the decoder to output just 0x80.

    Edit: If the receiver is only expecting the low byte of each character and character values 0x80-0xFF are valid, you will have to convert each character one at a time.

    int len = tempString.Length;
    byte[] msg = new byte[len];
    for ( int idx = 0; idx < len; ++idx )
    {
      msg[idx] = (byte) tempString[idx];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used following code to convert string to json and parse it. String
I have a following code in coffeescript to recursively list directories (converted from javascript):
I have the following code that is to be propperly converted to cython: from
I have the following FORTRAN code which I need to convert to C or
I have the following JavaScript code which I like to convert to jQuery but
I have never used Foxpro before. Can you convert the following Foxpro code into
I have the following code in my C# class which remotely connects to a
I have the following code (taken from actual script): $result=mysql_query($sql); while($row=mysql_fetch_assoc($result)) { $auth_token=$row['oauth_token']; $auth_token_secret=$row['oauth_token_secret'];
I have two tables in my entity data model (converted from an old database)
I have following html and css code in which I want <a> tag to

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.