Solved

How to define charset of UrlEncode ?

Posted on 2004-09-22
2
1,411 Views
Last Modified: 2010-05-18
I have a problem when I use the method Server.UrlEncode in ASP.NET (c#)
I would like to use this method to encode characters in iso-8859-1.
For some reason, I have to send a request to a web server in ISO-8859-1 and not in UTF-8. And I have the impression this method encodes all non-ASCII characters in 2-bytes codes. How to force it to encode in iso-8859-1.
For exemple, Server.UrlEncode("é")  returns  %c3%a9
But  I would like to get :   %E9
I need the feature to be dynamic. Sometimes, it can also be windows-1251 or any others.
0
Comment
Question by:fpasquier
2 Comments
 
LVL 28

Accepted Solution

by:
mmarinov earned 250 total points
ID: 12125628
Hi,

use
HttpUtility.UrlEncode (this.Request.Url.PathAndQuery, System.Text.Encoding.GetEncoding("iso-8859-1"));

i'm not sure just if this is the code of the page you should enter - iso-8859-1

HTH
Regards,
B..M
0
 

Author Comment

by:fpasquier
ID: 12125987
Ok, thanks a lot!!!! It works.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question