EngBrunoMachado
asked on
Sending special characters to vb application TCP/IP
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.Enc oding.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.Enc oding.Unic ode.GetByt es(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
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.Enc
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.Enc
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
good to know... had to be something obvious ;-)
so to know what the default is
System.Text.Encoding enc = System.Text.Encoding.Defau lt;
System.Diagnostics.Debug.W riteLine(e nc.Encodin gName);
System.Diagnostics.Debug.W riteLine(e nc.HeaderN ame);
System.Diagnostics.Debug.W riteLine(e nc.WebName );
System.Diagnostics.Debug.W riteLine(e nc.BodyNam e);
so to know what the default is
System.Text.Encoding enc = System.Text.Encoding.Defau
System.Diagnostics.Debug.W
System.Diagnostics.Debug.W
System.Diagnostics.Debug.W
System.Diagnostics.Debug.W
ASKER
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)...