1

I am developing a Web Services based on ASP.Net asmx web service. The server end will response byte[] to client encoded in UTF-8, and client to convert the byte[] to string.

My confusion is, the England pound character at server side (I dump just before the Http response is wrote, and the character at server side is correct to be England pound) will be received as ?? from client side.

Any ideas what is wrong? I suspect it is encoding issue, but I have no idea how to debug further and any settings (settings from client web service proxy?) which will impact?

Here is the header part which I got from Fiddler.

HTTP/1.1 200 OK Date: Fri, 20 Feb 2009 16:51:30 GMT Server: Microsoft-IIS/6.0 cache-control: no-cache pragma: no-cache X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Cache-Control: private Content-Type: text/xml Content-Length: 22752

xml version="1.0" encoding="utf-8"

1

1 Answer 1

1

The first thing to do is to sniff what's actually being sent, in terms of the headers, the XML declaration and the bytes forming the text itself.

Fiddler is good as an HTTP proxy, or you could use WireShark to sniff at the network level.

Once you've got those three bits of information (the Content-Type header, the XML declaration and the bytes making up the pound sign) if you update your answer we'll see what we can do. It does sound odd, as usually ASP.NET just gets all of this right.

What does your client side code look like? Is that just the normal .NET web service client code as well?

EDIT: Try to find a binary (hex dump) display in Fiddler so you can find the bytes.

However, I strongly suspect that the problem is merely with dumping the result to the console. Here's a bit of code to use to dump the unicode code points:

static void DumpString (string value)
{
    foreach (char c in value)
    {
        Console.Write ("{0:x4} ", (int)c);
    }
    Console.WriteLine();
}

I suspect you'll see an 00A3 in the output, which is the Unicode for the pound sign. That means the string has actually reached your client fine - but writing it out to the console is failing.

Sign up to request clarification or add additional context in comments.

17 Comments

I have just used Fiddler and posted the response. Any ideas, guru? :-)
I found in Fiddler, the content is correctly displayed as England pound, but in the string return value I got, the content is ?? (I dump it to Console and see ??).
I find US dollar sign could be displayed correctly. Does it mean default encoding UTF-8 does not work for England pound but works for U.S. dollar? :-)
$ is part of ASCII, whereas the pound sign isn't. I've edited my answer - I strongly suspect it's just your console rather than the web service client, but I've given you some code to check.
Jon, I have followed your solution to debug it, it is displayed as 003F 003F for ??, and not 003A. Any ideas?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.