Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8701077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:18:31+00:00 2026-06-13T02:18:31+00:00

Why the serialize behavior is difference in simulator and iPad device in monotouch? I

  • 0

Why the serialize behavior is difference in simulator and iPad device in monotouch?
I have declare the serialize behavior is UTF-8, but when send the serialize data from ipad device to WCF service, I trace the message, it change to ascii, why? (and in simulator it’s OK with UTF-8)

trace in simulator/Chinese Language:
< ?xml version=”1.0″ encoding=”utf-8″? >
…

trace in iPad device/Chinese Language:
< ?xml version=”1.0″ encoding=”us-ascii”? >
…

btw, I serialize the data manually with my static method: XmlSerialize.

    public static string XmlSerialize<T>(T obj)
    {
        using (MemoryStream ms = new MemoryStream())
        {
            XmlSerializer serializer = new XmlSerializer(typeof(T));
            serializer.Serialize(ms, obj);
            ms.Seek(0, SeekOrigin.Begin);
            using (StreamReader reader = new StreamReader(ms, Encoding.UTF8))
            {
                return reader.ReadToEnd();
            }
        }
    }


    public static T XmlDeserialize<T>(string xmlOfObject) where T : class
    {
        using (MemoryStream ms = new MemoryStream())
        {
            using (StreamWriter sr = new StreamWriter(ms, Encoding.UTF8))
            {
                sr.Write(xmlOfObject);
                sr.Flush();
                ms.Seek(0, SeekOrigin.Begin);
                XmlSerializer serializer = new XmlSerializer(typeof(T));
                return serializer.Deserialize(ms) as T;
            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:18:33+00:00Added an answer on June 13, 2026 at 2:18 am

    You need to setup XmlSerializer to use utf-8 as well:

    var serializer = new XmlSerializer(typeof(MyClass));
    
    using (var writer = new StreamWriter("file.path"))
    {
      using (var xmlWriter = XmlWriter.Create(writer, new XmlWriterSettings { Indent = false, Encoding = Encoding.UTF8 }))
      {
        serializer.Serialize(xmlWriter, myObject);
      }
    }
    

    Otherwise it will use the default encoding, whatever that happens to be.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have serialize values in data base, i fetch them from database then when
I have a problem with a WCF service, which tries to serialize too much
jQuery serialize() throws empty string from a form, here is the source of the
Is there anyway to serialize a List of datacontracts? I have created a datacontract
I have a problem with WCF deserialization where the client hangs on the response
I asked a similar question earlier How can I have jquery attach behavior to
I am seeing a weird behavior when I POST using AJAX. When I have
I'm trying to serialize an object as XML and have been using a little
I have an object that I serialize to XML. If one of the properties
I have a GridView and want to serialize column widths across sessions. My idea

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.