Single byte ISO-8859-1 characters from web service in VB.NET

Joined
May 25, 2007
Messages
1
Reaction score
0
Hello, I have a problem with what I believe is the return encoding in a web service made in VB.NET. In reality it's one of our customers' application that is broken but I'm able to reproduce it but not solve it. The web service is replying with a xml message that is recieved by a Linux system, therefor the solution needed is a minimum impact one made in the Web Service, if possible. In the xml message there is strings with special characters.

Below is a snippet of code from a simple function made in VB.NET

Public Function HandleMsg() As String

Dim b() As Byte = {255, 128, 234, 244}
Dim s As String = System.Text.Encoding.Default.GetString(b)
'Debug.WriteLine(s)
'Debug.WriteLine(System.Text.Encoding.Default.GetByteCount(s))
Return System.Text.Encoding.Default.GetByteCount(s)

Result:
String = ÿ€êô
Byte count = 4

Instead of using Debug.WriteLine I simply returned the String and the Byte Count in two tests and it replied exactly what it says above, four freaky chars and a byte count of 4.

However, when I look at that packages sent with a network sniffer, even though the byte count says 4, the string in the message contains 8! bytes. I dont want 8 bytes, I want 4. I've tried all kinds of suggestions found everywhere but nothing I change will make the function return the 4 bytes.

Following test case with the same function:

Return Chr(228)

which definitely should return one byte also returns two bytes in a network sniffer. I've tried everything available at msdn and a lot of other places without success. I've tried setting responseEncoding in globalization and lots of encoding settings in the code but to no avail.
What I would like is the function to return single byte strings in ISO-8959-1 encoding if possible, but really, Return Chr(228) should be one byte in a sniffer, not two.

Is there anyone out there with any helpful hints?

After browsing for possible solution I've come to the conclusion that I might be approaching this from the wrong angle but the .NET developer already gave up which I refuse to, so my angle of approach is the bulldozer way.

In this forum at this link
http://www.velocityreviews.com/forums/t77832-set-requestcontentencoding-from-code.html
I saw some possible solutions with the HttpApplication.BeginRequest but it's simply too advanced for me, .NET is not home turf for me, more like being dragged out in the desert against my will.

Anyone, please?
 

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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top