Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / January 2005

Tip: Looking for answers? Try searching our database.

HttpGetRequest's with Umlaut inside Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
edx - 21 Jan 2005 19:55 GMT
Hi,
I am trying to make a WebRequest (Method Get) to a webserver and I need to
transfer an Umlaut (ö) a QueryString. I have tried to encode it "by hand",
but whatever I try does not seem to work, e.g.:

HttpWebRequest ^wr = (HttpWebRequest ^)HttpWebRequest::Create
("http://www.google.com/search?q=L%C3%B6L");
   HttpWebResponse ^response = (HttpWebResponse ^)wr->GetResponse ();
   StreamReader ^sr = gcnew StreamReader (response->GetResponseStream (),
Encoding::ASCII);
   String ^answer = sr->ReadToEnd ();

It should send a request to google.com searching for "LöL" (without the
quotes).
Why doesn't this work? google Interprets the request as L??L

Thank you very much,
Felix Arends
Gary Chang[MSFT] - 22 Jan 2005 07:37 GMT
Hi Felix,

Currently I am looking for somebody who could help you on it. We will reply
here with more information as soon as possible.
If you have any more concerns on it, please feel free to post here.

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ??C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
Joerg Jooss - 22 Jan 2005 10:30 GMT
> Hi,
> I am trying to make a WebRequest (Method Get) to a webserver and I
[quoted text clipped - 11 lines]
> the quotes).
> Why doesn't this work? google Interprets the request as L??L

Note that there's no default character set defined for URL-encoding
non-ASCII characters. You're assuming UTF-8, which actually works with
Google.

You're also decoding the response using ASCII encoding, which loses all
umlaut characters (Google serves ISO-8859-1). I guess you also need to
send a couple of HTTP headers like Accept-Language, because Google
seems to take that into consideration as well.

Cheers,
Signature

http://www.joergjooss.de
mailto:news-reply@joergjooss.de

edx - 22 Jan 2005 11:37 GMT
Hi!
Thanks for your reply, I managed to do it. It seems that google consider's
the user-agent when processing the search request. So here's my new source
which works for "Umlauts" as well :)

   String ^r = String::Format
      ("http://www.google.com/search?hl=en&q={0}",
       s->ToString ());

   HttpWebRequest ^wr = (HttpWebRequest ^)HttpWebRequest::Create
(Uri::EscapeUriString (r));
   wr->Headers->Add ("Accept-Language:en-us");
   wr->Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, */*";
   wr->Headers->Add ("Accept-Encoding", "deflate");
   wr->UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
Maxthon; .NET CLR 1.1.4322; .NET CLR 2.0.41115)";

   HttpWebResponse ^response = (HttpWebResponse ^)wr->GetResponse ();

Thank you very much,
Felix Arends

> > Hi,
> > I am trying to make a WebRequest (Method Get) to a webserver and I
[quoted text clipped - 22 lines]
>
> Cheers,

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.