a string that has space between every char!?!?

  • Thread starter Thread starter Thor-Björn Andersson
  • Start date Start date
T

Thor-Björn Andersson

Hi

Im using MSMQ to send and then read messages. I use a Formatter
(http://support.microsoft.com/default.aspx?scid=kb;EN-US;310683), but I use
"Encoding.Unicode" instead of "Encoding.UTF8".

The problem im having is decode\convert the body of the messages to a
"proper" string.
There are spaces between all chars like: "H I T H E R E" (hi there), does
this have to do with the fact that it's in unicode or is it the StreamReader
that does this.

I really need a "proper" string, no extra spaces. Greatfull for all the help
i can get!!

Best regads
Tobbe
 
Tobbe,

You need to set the encoding on the other end to be Unicode. The reason
you are getting spaces is that those characters are actually being
interpreted as null characters.

On the reader on the other end, make sure you pass an instance of
UnicodeEncoding to the constructor.

Hope this helps.
 
Thanks Nicholas!

It work!


Nicholas Paldino said:
Tobbe,

You need to set the encoding on the other end to be Unicode. The reason
you are getting spaces is that those characters are actually being
interpreted as null characters.

On the reader on the other end, make sure you pass an instance of
UnicodeEncoding to the constructor.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Thor-Björn Andersson said:
Hi

Im using MSMQ to send and then read messages. I use a Formatter
(http://support.microsoft.com/default.aspx?scid=kb;EN-US;310683), but I use
"Encoding.Unicode" instead of "Encoding.UTF8".

The problem im having is decode\convert the body of the messages to a
"proper" string.
There are spaces between all chars like: "H I T H E R E" (hi there), does
this have to do with the fact that it's in unicode or is it the StreamReader
that does this.

I really need a "proper" string, no extra spaces. Greatfull for all the help
i can get!!

Best regads
Tobbe
 

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

Back
Top