Request.QueryString() is stripping out French characters

G

Guest

Hi, i am currently working on ASP.Net v1.0 and is encountering the following
problem. In javascript, I'm passing in:
"somepage.aspx?QSParameter=<RowID>Chèques</RowID>" as part of the query
string. However, in the code behind when I tried to get the query string
value by calling Request.QueryString("QSParameter"), the value I got is:
"<RowID>Chques</RowID>". The special character "è" has been stripped out.
The web.config file is currently set to use UTF-8 for request, response, and
file encoding. What could be causing characters like "è" to be stripped out
of the query string in the code behind? Do I need to set some other value or
use some special processing code? Thanks.
 
J

John Horst

Lu:

Open your aspx page and select "Save <<page name>> As..." The Save
button in the dialog should have a down arrow at the right of the
button. Click this and select "Save With Encoding". You will be asked
if you want to overwrite the file. Click Yes to this. You will then
get a dialog asking you to select Endcoding and Line Endings. Leave the
Line Endings alone, but select the "Unicode - Codepage 1200" option and
save the file.

What is happening is VS.NET is saving your aspx file an an ASCII file,
which only has one byte per character and as such cannot support foreign
language character sets. When you save it with encoding, it will save
it as a text file, but it will keep the second Unicode byte with the
file.

John

-----Original Message-----
From: Lu [mailto:[email protected]]
Posted At: Wednesday, August 31, 2005 2:20 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: Request.QueryString() is stripping out French characters
Subject: Request.QueryString() is stripping out French characters


Hi, i am currently working on ASP.Net v1.0 and is encountering the
following problem. In javascript, I'm passing in:
"somepage.aspx?QSParameter=<RowID>Chèques</RowID>" as part of the query
string. However, in the code behind when I tried to get the query
string value by calling Request.QueryString("QSParameter"), the value I
got is:
"<RowID>Chques</RowID>". The special character "è" has been stripped
out.
The web.config file is currently set to use UTF-8 for request, response,
and file encoding. What could be causing characters like "è" to be
stripped out of the query string in the code behind? Do I need to set
some other value or use some special processing code? Thanks.
 
J

Joerg Jooss

John said:
Lu:

Open your aspx page and select "Save <<page name>> As..." The Save
button in the dialog should have a down arrow at the right of the
button. Click this and select "Save With Encoding". You will be
asked if you want to overwrite the file. Click Yes to this. You
will then get a dialog asking you to select Endcoding and Line
Endings. Leave the Line Endings alone, but select the "Unicode -
Codepage 1200" option and save the file.

That won't help, but rather be harmful, without changing the
fileEncoding attribute in web.config to UTF-16LE. Since Lu's already
using UTF-8, this is a waste of time. The files must be stored as UTF-8
instead.
What is happening is VS.NET is saving your aspx file an an ASCII file,
which only has one byte per character and as such cannot support
foreign language character sets. When you save it with encoding, it
will save it as a text file, but it will keep the second Unicode byte
with the file.

That's not correct. ASP.NET seems to use the platform's default
encoding if no fileEncoding is specified, just like VS .NET does. I say
"seems", because that behaviour isn't documented.

If that platform default is for example Windows-1252, you can easily
save many special characters used in Western Europe natively in your
source files.

Cheers,
 
G

Guest

Hi, for this page, what we do is that we have an XML control on the ASPX
which we use to dynamically create a table based on data returned from our
business objects. This dynamic table that we render contains texts and
numbers that the user can click on to go a pop up that will show more info.
When the user clicks on the link, the javascript grabs the necessary
information from the dynamically render page and pass them as query string
parameters. So, the string "Chèques" is part of the data that is returned
from our business object and dynamically rendered on the screen. The string
is also used in the query string parameter when the user clicks on
appropriate link. What is happening now is that the page renders properly
with the correct text. The javascript is grabbing the correct test and
calling the popup window ASPX page with the correct query string parameter.
So if I put an alert() call in the javascript, I will see
"<RowID>Chèques</RowID>". However, when the popup window ASPX page's code
behind Page_Load() is called, the call to Request.QueryString() returns
"<RowID>Chques</RowID>". In the web.config, I have request, response, and
file encoding set to utf-8. So it seems like somewhere between when the page
is submitted, and the Page_Load() event is fired, the "è" character was
removed for some reason. The ASP.Net project is currently on framework v1.0
and upgrading is not an option currently.

Also, I have Window-1252 character code page installed according to
"Regional and Language Options" in control panel. Not sure how to set it as
the default code page though.

Any ideas or suggestions to solve this problem would be greatly appreciated.
Thanks.
 
J

Joerg Jooss

Lu said:
Hi, for this page, what we do is that we have an XML control on the
ASPX which we use to dynamically create a table based on data
returned from our business objects. This dynamic table that we
render contains texts and numbers that the user can click on to go a
pop up that will show more info. When the user clicks on the link,
the javascript grabs the necessary information from the dynamically
render page and pass them as query string parameters. So, the string
"Chèques" is part of the data that is returned from our business
object and dynamically rendered on the screen. The string is also
used in the query string parameter when the user clicks on
appropriate link. What is happening now is that the page renders
properly with the correct text. The javascript is grabbing the
correct test and calling the popup window ASPX page with the correct
query string parameter. So if I put an alert() call in the
javascript, I will see "<RowID>Chèques</RowID>". However, when the
popup window ASPX page's code behind Page_Load() is called, the call
to Request.QueryString() returns "<RowID>Chques</RowID>". In the
web.config, I have request, response, and file encoding set to utf-8.
So it seems like somewhere between when the page is submitted, and
the Page_Load() event is fired, the "è" character was removed for
some reason. The ASP.Net project is currently on framework v1.0 and
upgrading is not an option currently.

I guess that the JavaScript code uses a different encoding internally
when fetching the popup page. You could use a debugging proxy like
Fiddler (www.fiddlertool.com) to monitor your HTTP traffic.

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top