Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 28-10-2009
Member
 
Join Date: Jul 2009
Posts: 122
C# HttpWebRequest + accent

A script of counter in php, it must simulate opening a web page in my C# code. Here is what I use for now:
Code:
HttpWebRequest httpWRequest = (HttpWebRequest)WebRequest.Create("http://www.mysite/" + type_submit + "submit.php?user=" + user + "&" + type_submit + "=" + submit);
httpWResponse = (HttpWebResponse)httpWRequest.GetResponse();
What works very well the problem is on accents. When I send:

Jose Gonzalez

the registration on the server that makes the form:

Jos? ? Gonz? ?lez

if I typed the URL directly in Firefox, I have this problem of focus.

I think it must have to add something like:
Code:
encoding="ISO-8859-1"
but I do not know where to put
Reply With Quote
  #2  
Old 28-10-2009
Member
 
Join Date: Nov 2008
Posts: 1,054
Re: C# HttpWebRequest + accent

Try this:
Code:
HttpWebRequest httpWRequest = (HttpWebRequest) WebRequest.Create ( "http://www.mysite/" + type_submit + "submit.php?user=" + user + "&" + type_submit + "=" + submit) ;
httpWRequest. ContentType = "text/html; charset=ISO-8859-1" ;
httpWResponse = ( HttpWebResponse ) httpWRequest. etResponse ( );
Reply With Quote
  #3  
Old 28-10-2009
XSI XSI is offline
Member
 
Join Date: May 2008
Posts: 271
Re: C# HttpWebRequest + accent

Otherwise, you can do something like this:
Code:
UriBuilder uribuilder = new UriBuilder ( "http://www.mYsite/" + type_submit + "submit.php" ) ;
uribuilder. Query += "user=" + HttpUtility. UrlEncode ( user, Encoding. UTF8 ) + "&" + HttpUtility. UrlEncode ( type_submit, Encoding. UTF8 ) + "=" + HttpUtility. UrlEncode ( submit, Encoding. UTF8 ) ) ;
WebRequest webRequest = HttpWebRequest. Create ( uribuilder. Uri ) ;
Reply With Quote
  #4  
Old 28-10-2009
Member
 
Join Date: Jul 2009
Posts: 122
Re: C# HttpWebRequest + accent

Thank you all and it works finally!
What I replaced was:
Code:
HttpUtility.UrlEncode(submit, Encoding.UTF8)
by
Code:
HttpUtility.UrlEncode(submit, Encoding.GetEncoding("iso-8859-1" ))
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "C# HttpWebRequest + accent"
Thread Thread Starter Forum Replies Last Post
Custom accent color present in Nokia Lumia 800 NatwarL@L Portable Devices 2 25-11-2011 07:52 PM
Explorer crashes when I press any accent key FreddMartins Windows Software 3 03-10-2011 06:57 PM


All times are GMT +5.5. The time now is 04:41 PM.