all groups > c# > april 2006 >
You're in the

c#

group:

Special characters in Config file


Re: Special characters in Config file Jon Skeet [C# MVP]
4/13/2006 8:03:55 PM
c#:
[quoted text, click to view]

Assuming the configuration file is encoded in an encoding which=20
includes those characters (such as UTF-8) you can just include the=20
character in the text.

--=20
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
Re: Special characters in Config file Jon Skeet [C# MVP]
4/13/2006 9:45:29 PM
[quoted text, click to view]

Well, that's because you've got & in there instead of &amp;

Having changed that - and made sure that the file really was saved as=20
UTF-8 - the program runs fine.

--=20
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
Special characters in Config file JimmyW
4/13/2006 9:49:23 PM
Hello,

How characters é and ü should be coded into App.Config file?
For Example & must be converted to &amp; but how those two
characters é (e with dot) and ü (German u) should be coded?

Can anyone help?

Cheers!


Re: Special characters in Config file JimmyW
4/13/2006 11:06:41 PM
I tried to read file below

<?xml version="1.0" encoding="utf-8"?>
<BankAccount>
<Number>1234</Number>
<Name>James & Dean</Name>
<Type>Checking - é ü</Type>
<OpenDate>11/04/1934 </OpenDate>
<Balance>25382.20</Balance>
</BankAccount>

with XmlTextReader but an Exception thrown.

I thing that values inside Type tag should be indicated in diffrently but
how?
Or should I give XmlTextReader an option?

Reader code is below

namespace ReadXML
{
using System;
using System.Xml;
using System.Diagnostics;

public class ReadBankAccount
{
private const string m_strFileName = "c:\\account.xml";
[STAThread]
public static void Main()
{
XmlTextReader bankReader = null;
bankReader = new XmlTextReader (m_strFileName);

while (bankReader.Read())
{
if (bankReader.NodeType == XmlNodeType.Element)
{
if (bankReader.LocalName.Equals("Name"))
{
System.Diagnostics.Debug.WriteLine(String.Format("{0}
has balance of $",
bankReader.ReadString()));
}

if (bankReader.LocalName.Equals("Balance"))
{
System.Diagnostics.Debug.WriteLine(String.Format("{0}",
bankReader.ReadString()));
}
}
}
}
}



[quoted text, click to view]

Assuming the configuration file is encoded in an encoding which
includes those characters (such as UTF-8) you can just include the
character in the text.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Re: Special characters in Config file JimmyW
4/13/2006 11:58:27 PM
Thanks again Jon!!!!!

[quoted text, click to view]

Well, that's because you've got & in there instead of &amp;

Having changed that - and made sure that the file really was saved as
UTF-8 - the program runs fine.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

AddThis Social Bookmark Button