views:

23

answers:

1

Hi All,

Currently I have the following code:

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {

            var myObject = new MyObject() {Text = "€ 232.22"};

            StringBuilder sb = new StringBuilder();
            var xmlWriterSettings = new XmlWriterSettings();


            XmlWriter writer = XmlWriter.Create(sb, xmlWriterSettings);
            new XmlSerializer(typeof(MyObject)).Serialize(writer, myObject);

            Console.WriteLine(sb.ToString());
            Console.ReadKey();
        }
    }
    [Serializable]
    public class MyObject
    {
        public MyObject()
        {
        }
        [XmlAttribute()]
        public string Text { get; set; }
    }
}

And the issue I have id that currently the serializer when i give it a euro symbol € it returns a ?, so then I tried passing € but it encodes the & and returns € Anyone know of an elegant way to solve this issue?

Many thanks,

Chris

A: 

It's not the serialiser, it's the Console. Try Console.WriteLine("€"); or try Console.ReadKey(false); and then type € and you get the same results.

(Assuming that is, that your console fonts don't have a €, which the default don't).

The € character isn't a "special character" in anyway, but a font can't handle ABC if it doesn't have glyphs for them.

Jon Hanna