Xml Write 中文字編碼的問題

摘要: Xml Write 中文字編碼的問題

Encoding enc = Encoding.GetEncoding("big5");  
   
  XmlWriterSettings settings = new XmlWriterSettings();  
  settings.Indent = true;  
  settings.OmitXmlDeclaration = false;  
  settings.NewLineOnAttributes = true;  
  settings.Encoding = enc;  
  
  MemoryStream ms = new MemoryStream();  
  
  XmlWriter writer = XmlWriter.Create(ms, settings);  
  
  writer.WriteStartElement("root");  
  writer.WriteStartElement("person");  
  writer.WriteElementString("name", "游錫?、??創意");  
  writer.WriteEndElement();  
  writer.WriteEndElement();  
  writer.Flush();  
   
  string result = enc.GetString(ms.ToArray());  
  
  Response.ContentType = "text/xml";  
  Response.Write(result);