Error decoded 8 bit characters.

T

T Conti

Hello:

We ran into an issue with the decoding 8 bit characters. We have an
asp page that makes a call to an ashx page. When the HTTPHandler
accesses the query string we find that the 8 bit characters are
stripped. The source asp page is encoding using ISO-Western European
(windows-1252) single byte encoding. I am assuming that the .Net
framework uses the Unicode (UTF8) as the basis for decoding the URL.
Now we managed to get this to work by explicitly requesting that the
HTTPHandler use Windows-1252 for encoding/decoding:

<globalization
requestEncoding="Windows-1252"
responseEncoding="Windows-1252"/>

This works when the URL is passed using a single byte encoding but it
breaks when multi-byte encoding on the URL is used by the source page.
SO the solution is not extensible. This brings up a few questions:

1) Is there a way to programatically indicate the responseEncoding
using an aspx page.
2) Has anyone had luck with a more flexible approach to handling the
encoding/decoding of characters w/o have in to hard code the encoding
in the web.config.

Please let me know,
Thanks
 
J

Joerg Jooss

T said:
Hello:

We ran into an issue with the decoding 8 bit characters. We have an
asp page that makes a call to an ashx page. When the HTTPHandler
accesses the query string we find that the 8 bit characters are
stripped. The source asp page is encoding using ISO-Western European
(windows-1252) single byte encoding. I am assuming that the .Net
framework uses the Unicode (UTF8) as the basis for decoding the URL.
Now we managed to get this to work by explicitly requesting that the
HTTPHandler use Windows-1252 for encoding/decoding:

<globalization
requestEncoding="Windows-1252"
responseEncoding="Windows-1252"/>

This works when the URL is passed using a single byte encoding but it
breaks when multi-byte encoding on the URL is used by the source page.
SO the solution is not extensible. This brings up a few questions:

1) Is there a way to programatically indicate the responseEncoding
using an aspx page.

Yes. You can set the property HttpResponse.ContentEncoding.
2) Has anyone had luck with a more flexible approach to handling the
encoding/decoding of characters w/o have in to hard code the encoding
in the web.config.

On general: if your clients are properly communicating the appropriate
encoding, you can retrieve that value from the HTTP request and apply it. If
they don't, you're out of luck.

Cheers,
 

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

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top