TGuimond
TGuimond

Reputation: 5487

ASP.NET - Invalid character in the given encoding .resx

I am adding a number of languages to a client's website using the App_LocalResource folder containing .resx files.

The client's test application is hosted on a server with no outside Internet access so I have to remote desktop to the site and manually copy any changes made via Notepad..

So far, I have manually created an App_LocalResource folder, created the .resx files and copied the source of each file via Notepad.

I am now getting a parser error:

Parser Error Message: Invalid character in the given encoding.

Line 137:  </data>
Line 138:  <data name="DEATHINSERVICENOMINATIONS" xml:space="preserve">
Line 139:    <value>Mort à candidatures Prestation de service</value>
Line 140:  </data>
Line 141:  <data name="EDITPERSONALDATA" xml:space="preserve">

Would this possibly have something to do with me manually copying these files across using Notepad or is there another reason for it?

I have added this to the web.config file:

<globalization fileEncoding="utf-8"
    requestEncoding="utf-8"
    responseEncoding="utf-8"/>

Upvotes: 5

Views: 4014

Answers (2)

Milimetric
Milimetric

Reputation: 13549

I'm not sure, but your RESX file probably needs to identify itself to the XML parser as UTF-8. One way to be sure what's causing it is to use binary search (remove half the file at a time recursively) until you find the part that's causing the problem. Then, if you need, you can use CDATA to escape any characters the parser doesn't like.

Upvotes: 1

Rubens Farias
Rubens Farias

Reputation: 57956

Try to add an encoding property in your resx file, at first line, like this:

<?xml version="1.0" encoding="ISO-8859-1"?>

Upvotes: 6

Related Questions