tim_bo05
tim_bo05

Reputation: 13

Special characters in web.config

I've create a custom configuration section in my web.config file for my 3.5 web application. The custom configuration contains special characters listed below.

  <add Key="2" String="â€"/>
  <add Key="3" String="148"/>
  <add Key="4" String="!X"/>
  <add Key="5" String="¡§"/>
  <add Key="6" String="¡¦"/>
  <add Key="7" String="¡¨"/>
  <add Key="8" String="’" />
  <add Key="9" String="–" />

I currently have the xml type of the web.config defined as below.

<?xml version="1.0"?>

This works fine in one development environment, but when I migrate the application to another environment I get an xml parsing error on the string for Key 2. When I replace all the string definitions for each config entry with standard alpha chars, the application works fine. Is there a way to enforce the XML to be read the same way? I have looked into the encoding attribute for the xml definition tag, just not positive what to set it to. Any guidance would be well appreciated. Thanks in advance.

Upvotes: 0

Views: 2410

Answers (2)

Joel Rondeau
Joel Rondeau

Reputation: 7586

I recommend setting the encoding to "utf-8". Make sure the file is also actually saved as utf-8.

Upvotes: 3

Jonathan Wood
Jonathan Wood

Reputation: 67223

Are you typing these into your web.config file manually? Can't you just HTML-encode your string values?

Upvotes: 0

Related Questions