Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Sending special characters to vb application TCP/IP

Posted on 2004-09-10
4
270 Views
Last Modified: 2010-04-15
I am not so sure if I should post this in VB or C# forum - but let's see what happens...

I am building a simple client/server solution...
the server side I decided to build in C# (i need thread's and some other feturings that VB doesn't handle very well)...
the client side - a vb6 app... quite simple... the problem I got...

to send from C# to VB (sockets - TCP/IP) I do something like:
myTCP.Send(System.Text.Encoding.UTF8.GetBytes(Dados)); //Dados = string ie. "Test" or "Ligação"

VB receives the string and the data is not clear when sending characteres like "ç","é","ã"...
I searched for this and found that I would have to send from C# like:
myTCP.Send(System.Text.Encoding.Unicode.GetBytes(Dados));
but when I do this, I found a new problem - instead of getting "Ligação" > I receive something Like
L*i*g*a*ç*ã*o > * means (char)0 >>> or I don't receive the whole message...

I wonder how to send this special characteres (and they are very common) from C# to VB...
if I have no choice, I may create a simple "Convert Table" - Converting the "garbage" from the received message into the expected...

TIA
Bruno
0
Comment
Question by:EngBrunoMachado
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
tomasX2 earned 125 total points
ID: 12029194
1. could it possibly be BigEndianUnicode ....
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtextencodingclassbigendianunicodetopic.asp

what is the format the vb client expecting?
0
 

Author Comment

by:EngBrunoMachado
ID: 12029328
BigEndianUnicode gives me the same problem I had with Unicode...

about VB "All VB strings are stored in UNICODE" (http://www.mvps.org/vb/index2.html?tips/varptr.htm)

when I use Encoding.Unicode at C# Server, it sends me 2 bytes instead of 1 (and I believe it is ANSI)...

0
 

Author Comment

by:EngBrunoMachado
ID: 12029416
hmmm...
it couldn't be more simple than that...
I was trying Unicode / UTF8...
and it was Default all the time...

I had to try them all after the BigEndian...
well... thx
0
 
LVL 5

Expert Comment

by:tomasX2
ID: 12029461
good to know... had to be something obvious ;-)

so to know what the default is

      System.Text.Encoding enc = System.Text.Encoding.Default;

      System.Diagnostics.Debug.WriteLine(enc.EncodingName);
      System.Diagnostics.Debug.WriteLine(enc.HeaderName);
      System.Diagnostics.Debug.WriteLine(enc.WebName);
      System.Diagnostics.Debug.WriteLine(enc.BodyName);
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question