Encoding bug in SP2?

N

Niklas Björkman

Hi,
I´ve installed SP2 for CF today and ran into problems with my socket
communication -
a problem that was not there prior to the upgrade.

From my server i send a stream of bytes using UTF-encoding and use
UTF-encoding
on the Pocket PC to unpack the stream like this:

---------------------------------
Server (WinXP):
---------------------------------

Encoding encode = Encoding.UTF8;
Byte[] buffer encode.GetBytes("<Message>Tally ho</Message>");
// Pseudocode
Socket.Send(.... (Message is send using socket)

---------------------------------
Client (PocketPC compact Framework)
---------------------------------

// Pseudocode
Byte[] buffer = Socket.Receive... (You get the picture)

Encoding encode = Encoding.UTF8;
String data = encoding.GetString(buffer, 0, buffer.Length);


Here is the funny part: Prior to the upgrade the "data" variable was my
message
send from the server but now the "data" is the message with three added
characters "\0\0\0" at the end of the string. So when I look at the message
at
the PocketPC it reads "<Message>Tally ho</Message>0\0\0\". Is there
something
new with the socket and/or the encoding that I have missed or is this a bug?

A workaround is, naturally, removing all three characters at the end of the
message,
but if this is a bug that will be fixed I do not like to send the
application out to my
customers with a Quick-And-Dirty fix.

Regards
Niklas
 
F

Fernando

Hi Niklas,

Would you mind posting some small repro code?
Also, could you please tell me which OS version you are using?

Thx
Fernando
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Niklas Björkman" <[email protected]>
| Subject: Encoding bug in SP2?
| Date: Tue, 13 Jan 2004 16:04:38 +0100
| Lines: 49
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: 213.214.237.38
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.
phx.gbl
| Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.compactframework:42896
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hi,
| I´ve installed SP2 for CF today and ran into problems with my socket
| communication -
| a problem that was not there prior to the upgrade.
|
| From my server i send a stream of bytes using UTF-encoding and use
| UTF-encoding
| on the Pocket PC to unpack the stream like this:
|
| ---------------------------------
| Server (WinXP):
| ---------------------------------
|
| Encoding encode = Encoding.UTF8;
| Byte[] buffer encode.GetBytes("<Message>Tally ho</Message>");
| // Pseudocode
| Socket.Send(.... (Message is send using socket)
|
| ---------------------------------
| Client (PocketPC compact Framework)
| ---------------------------------
|
| // Pseudocode
| Byte[] buffer = Socket.Receive... (You get the picture)
|
| Encoding encode = Encoding.UTF8;
| String data = encoding.GetString(buffer, 0, buffer.Length);
|
|
| Here is the funny part: Prior to the upgrade the "data" variable was my
| message
| send from the server but now the "data" is the message with three added
| characters "\0\0\0" at the end of the string. So when I look at the
message
| at
| the PocketPC it reads "<Message>Tally ho</Message>0\0\0\". Is there
| something
| new with the socket and/or the encoding that I have missed or is this a
bug?
|
| A workaround is, naturally, removing all three characters at the end of
the
| message,
| but if this is a bug that will be fixed I do not like to send the
| application out to my
| customers with a Quick-And-Dirty fix.
|
| Regards
| Niklas
|
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top