views:

109

answers:

1

I have a bug where special characters (danish 'ø' in this case) are shown correctly when running locally, but wrong when the code runs on a server (I get a pipe '|'). I was trying to solve this today, but I did not have access to the server, other than updating the code files. I will limited access monday, so I can at least write intermediate results to a log file, but to be prepared I thought I'd ask for suggestions here.

Program flow:

A C# test calls my own web service via a WebRequest. This web service calls an external web service via another web request.

When running my own web service locally I get correct results returned from the external web service.

When deploying the code to the server the external web service returns an error; it didn't find the word I was searching for. Except that I entered 'Bøssemagergade', but the word it complains about is returned as 'B|ssemagergade'. What can cause this difference? AFAIK the server runs with the exact same regional settings as my local machine.

I'm sure this is common stuff, but I haven't been doing web services before (I do feel at home with C#/.NET though, and know about encodings etc.).

Thanks!

A: 

You need to check your data at every stage in the process. Make sure you understand which encoding you're using (try to avoid using Encoding.Default) and verify the binary data going across the wire with something like WireShark.

See my debugging unicode problems article for further information.

Jon Skeet
Sorry, I forgot to close this question. It was actually caused by spaghetti code (not by me :) that seemed ok but had subtle errors (double encoding was happening). But your suggestions were good, so I'll accept the answer.
Sorry, I forgot to close this question. It was actually caused by spaghetti code (not by me :) that seemed ok but had subtle errors (double encoding was happening). But your suggestions were good, so I'll accept the answer.