473,786 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WEBRESPONSE ENCODING PROBLEM

I have a function which takes some parameters and gets a web page which
includes some specific Turkish characters. Im using UTF-8 encoding , but in
my response text there are ? charecters instead of some Turkish characters.
What can be the problem ?

Public Function IstekYap(ByVal PosURL As String, ByVal Method As String,
ByVal YollanacakVeri As String)

Dim objURI As Uri = New Uri(PosURL)

Dim objWebRequest As WebRequest = WebRequest.Crea te(objURI)

Dim body() As Byte

Dim requestStream As System.IO.Strea m

Dim encoding As New System.Text.UTF 8Encoding

objWebRequest.M ethod = Method

objWebRequest.C ontentType = "applicatio n/x-www-form-urlencoded"

body = encoding.GetByt es(YollanacakVe ri)

objWebRequest.C ontentLength = body.Length

requestStream = objWebRequest.G etRequestStream

requestStream.W rite(body, 0, body.Length)

Dim objWebResponse As WebResponse = objWebRequest.G etResponse()

Dim objStream As Stream = objWebResponse. GetResponseStre am()

Dim objStreamReader As StreamReader = New StreamReader(ob jStream,
System.Text.Enc oding.UTF8)

Dim strHTML As String = objStreamReader .ReadToEnd

Return (strHTML)

End Function

///////////////////////////////////////////////////////////////

Dim str As String

str = (((IstekYap(http://xx.com, "POST", "?str=1"))) )

Dim writer As New StreamWriter("c :\deneme.html", False,
System.Text.Enc oding.UTF8)

writer.Write(st r)

writer.Flush()

writer.Close()
Sep 17 '07 #1
1 2419
Better to post on the aspnet newsgroup,
<in da clubwrote in message
news:uu******** ********@TK2MSF TNGP03.phx.gbl. ..
>I have a function which takes some parameters and gets a web page which
includes some specific Turkish characters. Im using UTF-8 encoding , but in
my response text there are ? charecters instead of some Turkish characters.
What can be the problem ?

Public Function IstekYap(ByVal PosURL As String, ByVal Method As String,
ByVal YollanacakVeri As String)

Dim objURI As Uri = New Uri(PosURL)

Dim objWebRequest As WebRequest = WebRequest.Crea te(objURI)

Dim body() As Byte

Dim requestStream As System.IO.Strea m

Dim encoding As New System.Text.UTF 8Encoding

objWebRequest.M ethod = Method

objWebRequest.C ontentType = "applicatio n/x-www-form-urlencoded"

body = encoding.GetByt es(YollanacakVe ri)

objWebRequest.C ontentLength = body.Length

requestStream = objWebRequest.G etRequestStream

requestStream.W rite(body, 0, body.Length)

Dim objWebResponse As WebResponse = objWebRequest.G etResponse()

Dim objStream As Stream = objWebResponse. GetResponseStre am()

Dim objStreamReader As StreamReader = New StreamReader(ob jStream,
System.Text.Enc oding.UTF8)

Dim strHTML As String = objStreamReader .ReadToEnd

Return (strHTML)

End Function

///////////////////////////////////////////////////////////////

Dim str As String

str = (((IstekYap(http://xx.com, "POST", "?str=1"))) )

Dim writer As New StreamWriter("c :\deneme.html", False,
System.Text.Enc oding.UTF8)

writer.Write(st r)

writer.Flush()

writer.Close()


Sep 17 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3648
by: Jonax | last post by:
Hi guys, I have the following code that retrieves a webpage. My problem is getting it to use the right encoding. I've tested it against a danish page, but it won't show the danish characters. When I set it to sniff the encoding (using sr = New System.IO.StreamReader(strm, True) ) it sets it to UTF8, but when I browse the page using MSIE with auto-selection of encoding, it uses Western European (and displays the danish chars correctly).
0
2766
by: Johann Blake | last post by:
In my need to decode a JPEG 2000 file, I discovered like many that there was no functionality for this in the .NET Framework. Instead of forking out a pile of cash to do this, I came up with the idea that costs nothing and it is inheritently built into the Framework. So here is the solution... When you use the WebRequest and WebResponse classes to obtain graphics from a web site, these classes have built-in decoding for JPEG 2000 files....
2
9704
by: gizmo | last post by:
Hi, I'm using the following code to request the html source from the quoted site. ...... string url = "http://www1.soccerstand.com/"; WebRequest webRequest = WebRequest.Create(url); WebResponse webResponse = webRequest.GetResponse(); beginStr = new StreamReader(webResponse.GetResponseStream(),
0
1326
by: Tony Archer | last post by:
Here's my problem... When I use this code to hit the site in question I'm redirected to another SSL login page. If processed successfully the page creates a cookie and then redirects you to the original request. However, my code cannot seem to hold onto the cookie it creates. Does anyone know how to do this?
0
3107
by: Mamatha | last post by:
Hi I have developed one application in VB.NET which extracts the source code of Web pages.I gave a bunch of URLs in a listbox while at the time of response from the web it was struckup.Sometimes it gives output but sometimes it was struckup,i don't know the reason why it was strucked. If u know please let me know.Here it my source code.
4
1909
by: Savas Ates | last post by:
I have a vb.net web application. I want to post some variables to another web page and take some values back and process them. This is codes in my target url. I should post "langpair" cariable to my target url and it will respond with a value depend on a value which i send. <SELECT name=langpair><OPTION value=en|de>English to German</OPTION><OPTION value=en|es>English to Spanish</OPTION> </select>
1
8207
by: Mr Flibble | last post by:
OK I logon to a web site and I manage to get an SMSESSION cookie that I then store in a variable called _session (a class scoping variable). I do this by calling a logon URL and setting a cookie to SMCHALLANGE=YES to allow me to obtain a session. I then iterate the cookie collection to extract the SMSESSION value. All is good (so far). This is when the sky turns grey and the rain starts to fall. I then use this SMSESSION in a web...
6
13234
by: nakul.reddy | last post by:
I'm trying to use HTTPWebRequest to POST data to a website using multipart/form-data. It's HTTPS, and it returns a response object with -1 ContentLength. Any help would be appreciated! Below is my code: private string HTTPPost(string URI, string Parameters) {
0
1107
by: deeps1512 | last post by:
hi All, I have written the following code to get a webresponse. XmlDocument myxmlDoc1 = new XmlDocument(); myxmlDoc1.LoadXml(BkXMLRQ); string s = myxmlDoc1.OuterXml; System.Text.ASCIIEncoding encoding1 = new System.Text.ASCIIEncoding(); Byte byt1 = encoding.GetBytes(myxmlDoc1.OuterXml);
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8989
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.