Menu

#29 Encoding

open
None
5
2006-02-28
2006-02-21
Anonymous
No

Hi,

My compliments on the usefullness of this library. I
have one request/question about using this library
with alternate encoding. When creating the xml config,
there is no UTF-8 or UTF-16 or ASCII encoding
declaration or choice. The actual encoding is unknown
to all but NINI itself. This would be useful for other
readers of the same config data that require encoding
knowledge. Thanks.

Regards,
Alan

Discussion

  • Brent R. Matzelle

    • assigned_to: nobody --> bmatzelle
     
  • Brent R. Matzelle

    Logged In: YES
    user_id=163900

    Nini already has this support. Here is how you load it with
    UTF-8:

    --------
    using System.IO;
    using System.Text;

    StreamReader reader = new StreamReader("myFile.xml",
    Encoding.UTF8);
    XmlConfigSource source = new XmlConfigSource(reader);
    --------

    Here is how to save it in UTF-8:

    --------
    using System.IO;
    using System.Text;

    StreamWriter writer = new StreamWriter("myFile.xml", true,
    Encoding.UTF8);
    source.Save(writer);
    --------

     

Log in to post a comment.

MongoDB Logo MongoDB