tags:

views:

733

answers:

1

I have an object like this:

public class adapterContext {
    public HttpRequest Request;
}
adapterContext ac = new adapterContext();
ac.Response = context.Response;

I pass this object to my functions and use ac.Request[""] to get my url variables. However this somehow does not translate national/special characters correct. When I use f.ex this as part of the URL: prospectName=Tester+%e6+%f8+%e5

I get "Tester ? ? ?"

From the debugger I get: ac.Request["prospectName"][7] 65533 '�' char

Anyone have any idea how I should fix this?

+3  A: 

there's a nice function, you should take care of: HttpUtility.UrlDecode(string, Encoding) ... otherwise you need to adjust the globalization setting in your web.config (requestEncoding, responseEncoding ...)

Andreas Niedermair
This does nothing, I tried UTF-8, ASCII and unicode.
devzero
Btw, firebug shows that the valid encoding should be UTF-8 witch should be de default, so globalization and urlDecode should not be needed.
devzero
i suggest you use certain umlauts which aren't escaped. have you ever tried something like iso-8859-1?? you have 2 choices: either you set the globalization to your encoding, or you pass the values proper decoded
Andreas Niedermair
After having debugged a while I found the web application to switch encoding more or less in the middle of calls. This was apparently caused by a ajax POST, once I switched to GET it AND set the encoding to iso-8859-1 it worked.
devzero
One of the other weird things I noticed was that using Firefox on my development machine and url containing ÆØÅ (not escaped) worked fine. While using the same URL/browser on the prod platformed got me ???. I also noticed that UrlEncode with utf-8 was diffrent from the iso-8859-1 encode.
devzero
I think the correct solution would be to do UTF-8 urlEncode in the first place, unfortantly this is not as easy as it has to be done inside a SQL server trigger...
devzero
decoding is indeed a bit weird: some browser switch the encoding to the encoding of the server and not the encoding for the specific page...
Andreas Niedermair