473,410 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

WebClient UploadValues UTF-8

Ken
We are using the UploadValues function to post a xml string to a java web
service. This has been working well for us be we are running into an issue
with using Western European characters. The service is telling us that they
are receiving "junk" in place of the European characters. We have traced
through our code and it we have verified that it is working correctly all the
way up to when we call this function. Unfortunately, so far we have been
unable to see what is being sent. My question is, can this function be
causing the characters to somehow be translated into "junk"? From my reading
it uses UTF-8 internall and therfor should not be causing a problem. Thanks
for any help!

Ken
Nov 19 '05 #1
2 2140
I am not sure that my suggestion applies to your scenario. You did not provide enough info.

Here is what i have.
We have a service that returns XML as a string back to the caller. Our XML was generated from the object using XmlSerializer.

And we had similar situation like you have, we have been loosing European characters.
The problem was in the string itself.
Unfortunately XmlSerilaizer is using default encoding and you can not change it.

Here is a workaround.

---------------------
StringWriterWithEncoding sr = new StringWriterWithEncoding();
sr.SetEncoding(System.Text.ASCIIEncoding.UTF8);
XmlSerializer writeSerializer = new XmlSerializer(typeof(YOUROBJECT));
writeSerializer.Serialize(sr, doc);
--------------------------------------------------

public class StringWriterWithEncoding : StringWriter
{
private System.Text.Encoding _encoding = null;
public StringWriterWithEncoding()
{
}

public void SetEncoding( System.Text.Encoding encoding)
{
_encoding = encoding;
}

public override System.Text.Encoding Encoding
{
get
{
if( _encoding != null )
return _encoding;
else
return base.Encoding;
}
}

}
George.


"Ken" <Ke*@discussions.microsoft.com> wrote in message news:2D**********************************@microsof t.com...
We are using the UploadValues function to post a xml string to a java web
service. This has been working well for us be we are running into an issue
with using Western European characters. The service is telling us that they
are receiving "junk" in place of the European characters. We have traced
through our code and it we have verified that it is working correctly all the
way up to when we call this function. Unfortunately, so far we have been
unable to see what is being sent. My question is, can this function be
causing the characters to somehow be translated into "junk"? From my reading
it uses UTF-8 internall and therfor should not be causing a problem. Thanks
for any help!

Ken
Nov 19 '05 #2
Ken wrote:
We are using the UploadValues function to post a xml string to a java
web service. This has been working well for us be we are running
into an issue with using Western European characters. The service is
telling us that they are receiving "junk" in place of the European
characters. We have traced through our code and it we have verified
that it is working correctly all the way up to when we call this
function. Unfortunately, so far we have been unable to see what is
being sent. My question is, can this function be causing the
characters to somehow be translated into "junk"? From my reading it
uses UTF-8 internall and therfor should not be causing a problem.
Thanks for any help!


Does the receiving end really use UTF-8?

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 19 '05 #3

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

Similar topics

0
by: ryanbaldwin | last post by:
Hi, I'm writing a simple little application that posts to a Uri using the System.Net.WebClient class. In my application I wish to throw an Exception if anything other than a 200 OK is returned. ...
2
by: Max Gattringer | last post by:
Hi, I've got a little problem with the WebClient, I always get a failure while debugging this code: private void menuItem2_Click(object sender, System.EventArgs e) { NameValueCollection...
0
by: Kumar | last post by:
Hi all, I have the following code which uses WebClient.UploadValues myNameValueCollection.Add("Name", name) myNameValueCollection.Add("Age", age) .............. ............. Dim web As New...
3
by: Manuel | last post by:
I have an asp page ("test.asp") that presents the data it receives from a post.When I try the following code, test.asp doesn't return the values (supposedly) posted to it. If I make a web page with...
0
by: DrBytes | last post by:
Hi, .. I'm trying to post some values to an aspx but seem to be unable to get the formdata there . This is what I do: NameValueCollection form = new NameValueCollection(); form.Add("foo",...
0
by: parez | last post by:
Hi all! The webclient class's uploadvalues method appends %0d%0a to the last value in the name value collection.. Can any one help me out.. Thanks in advance.. Here is code...
3
by: Giggi | last post by:
Hi! I need to pass some strings via an HTTP POST from page1 (in my app) to a page on another server. I stored my data in a NameValueCollection and then sent it using WebClient.UploadValues....
1
by: jaffar.kazi | last post by:
Hi All, I have a .NET Winforms application that regularly posts to a PHP page. Till a few days back this worked perfectly. However, now, on certain machines, after the data is sent to the server,...
0
by: Juliano.net | last post by:
I have a program that uses WebClient.UploadValues method to send login information to a web site. It works fine on Windows XP, but on Windows Vista the users seems to be sent wrong, because the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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...
0
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...
0
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...

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.