473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Special characters in Config file

Hello,

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

Can anyone help?

Cheers!

Apr 13 '06 #1
4 7567
JimmyW <Ji****@hotmail.com> wrote:
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?


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 - <sk***@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
Apr 13 '06 #2
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()));
}
}
}
}
}

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
JimmyW <Ji****@hotmail.com> wrote:
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?


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 - <sk***@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
Apr 13 '06 #3
JimmyW <Ji****@hotmail.com> wrote:
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.


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 - <sk***@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
Apr 13 '06 #4
Thanks again Jon!!!!!

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
JimmyW <Ji****@hotmail.com> wrote:
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.


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 - <sk***@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
Apr 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Roy W. Andersen | last post by:
I've been searching google about this for days but can't find anything, so I'm hoping someone here can help me out. I'm trying to create zip-files without needing the zip-file extension in PHP,...
3
by: fowlertrainer | last post by:
Hi ! I'm hungarian, we use special characters like: á - a' õ -o" etc. I want to encode this characters to in config file I see these characters as \nnn format.
2
by: Mikael Engdahl | last post by:
Hi, I have a situation on an ASP.NET page on which I do a simple Response.Write(Request.Params). The problem is that when the parameters include special characters like ä or é they are...
4
by: SMG | last post by:
Hi All, I have created an application which is working fine and is in about to launch, now suddenly my mgmt says there are chances that Scrip ID( a particular id and not prim key) may have special...
3
by: SMG - Idealake | last post by:
Hi All, I have created an application which is working fine and is in about to launch, now suddenly my mgmt says there are chances that Scrip ID( a particular id and not prim key) may have special...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
1
by: Nergock | last post by:
Hi, Does anyone know how to handle special characters like "<" and ">" in the web.config file? Something like this would cause my app to not startup. <add key="SenderEmail" value="John Doe...
7
by: Trac Bannon | last post by:
When I load XML from a file into a dotNet XMLDataDocument, the UTF-8 codes are resolved but the 5 special XML entities are not. How can I force those 5 special character types to be translated?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.