Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XmlSerializer Utf-8 encoding

Consider the code below

  XmlSerializer serializer = new XmlSerializer(typeof(Invoice));

  using (TextWriter writer = new StreamWriter(fileName))
  {
    // Serialize the object, and close the TextWriter.
    serializer.Serialize(writer, invoice);
    writer.Close();
  }

No encoding is set on the stream writer by default. Does it default to UTF-8 if you don't set an encoding on the stream writer?

like image 515
AJM Avatar asked Nov 20 '09 10:11

AJM


People also ask

What is XML encoding utf8?

Unicode Transformation Format, 8-bit encoding form is designed for ease of use with existing ASCII-based systems and enables use of all the characters in the Unicode standard.

Is XML an utf8?

xml version="1.0" encoding="ISO-8859-1"?> Without this information, the default encoding is UTF-8 or UTF-16, depending on the presence of a UNICODE byte-order mark (BOM) at the beginning of the XML file.

What does XML version mean?

It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. The World Wide Web Consortium's XML 1.0 Specification of 1998 and several other related specifications—all of them free open standards—define XML. XML (standard) Extensible Markup Language. Abbreviation.


1 Answers

Yes, by default StreamWriter is created for using UTF-8 without preamble. See details here

like image 178
elder_george Avatar answered Sep 19 '22 18:09

elder_george