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 / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

WebClient UploadValues UTF-8

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ken - 14 Jul 2005 19:39 GMT
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
George - 14 Jul 2005 22:08 GMT
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.

 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
Joerg Jooss - 16 Jul 2005 13:41 GMT
> 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
[quoted text clipped - 7 lines]
> 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,
Signature

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


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.