Hans Rasmussen

info@hansrasmussen.com, +46 (0)723 207008

Encoding in your Visual Studio project

Have you experienced problems in your Visual Studio projects that no matter which encoding you try to use in your pages <?xml version=”1.0″ encoding=”iso-8859-1″?> for XML or <meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ /> but still you have problems solving swedish characters such as å, å and ö when posting information to external webservice etc.

 Try and configure your application’s web.config file and add encoding to your globalization element and now things are working way better.

 <system.web>

    <globalization

               fileEncoding=”iso-8859-1″

               requestEncoding=”iso-8859-1″

               responseEncoding=”iso-8859-1″

        />

</system.web>

 This behavior to determine encoding is probably the reason why a WebForm intitially contains no information about encoding at all.

<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”WebForm1.aspx.cs” Inherits=”WebForm1″ %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>

<html xmlns=”http://www.w3.org/1999/xhtml” >

<head runat=”server”>

    <title>Untitled Page</title>

</head>

<body>

    <form id=”form1″ runat=”server”>

    <div>

    </div>

    </form>

</body>

</html>

More information can be found on Microsoft Website regarding Globalization

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

*