locked
Precompiled code in wrong encoding RRS feed

  • Question

  • User-1878396931 posted

    Hi!

    I'm using Web Deployment Project for VS 2005. I'm using precompliation when I'm building my MSI-package. My problem is that when I publish my code on my web server the precompiled code or text gets wrong encoding. I'm using swedish letters (å,ä,ö) in my web page, and these letters are translated wrong (for example ? for the letter ä). All text, though, that is dynamically created on the webbserver (for example retrieved from the database) gets right encoding. I'm using US-English OS (Vista), with Location set to Sweden. Anyone who knows what the issue might be? 

     Grateful for any answer!

    Thursday, March 6, 2008 7:38 AM

Answers

  • User-762694769 posted

    I just tried the following steps on my machine. My OS is Win2k3 English, but not sure whether that makes any difference.

    1. Create new C# web site in VS.

    2. In default.aspx, pasted the characters: å,ä,ö

    3. Save default.aspx as Western Europe - Codepage 1252.

    4. Open default.aspx.cs.

    5. Add Response.Write("å,ä,ö"); in Page_Load

    6. Save default.aspx.cs as Western Europe - Codepage 1252.

    7. In web.config specify <globalization requestEncoding="iso-8859-1" responseEncoding="iso-8859-1" fileEncoding="iso-8859-1" culture="sv-SE" uiCulture="sv-SE"/>

    8. Ctrl-F5. I see all 6 charcters.

    9. Publish to c:\website1_out . (I tried both updatable and non-updatable with same results)

    10. Create IIS virtual directory to point to c:\website1_out

    11. Browse the website, I see all 6 characters.

     

    Could you try the above steps in a new web site on your machine to see what happens?

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 11, 2008 2:17 PM

All replies

  • User-762694769 posted

    Perhaps you could try explicitly specifying the file encoding you are using in web.config?

    <globalization fileEncoding="utf-8" . . ./>

    http://msdn.microsoft.com/en-us/library/hy4kkhe0.aspx

    Thursday, March 6, 2008 12:59 PM
  • User-1878396931 posted

    Ok, i checked the file encoding which is set "iso-8859-1", which should be right, the problem is that the compiler seems to discard this setting (or the settings in the web-config) when pre-compiling the code (I guess it uses the default setting which is "utf-8" or the OS native settings...which one I'm not sure).

    <globalization requestEncoding="iso-8859-1" responseEncoding="iso-8859-1" fileEncoding="iso-8859-1" culture="sv-SE" uiCulture="sv-SE"/>

     

    Friday, March 7, 2008 4:48 AM
  • User-762694769 posted

    Are you using Visual Studio to edit your source files (aspx, aspx.cs)? I am not sure how the OS and UI culture affect the file encoding of these source files in VS. It might be the case that they are saved as UTF-8 by default. Open up the file using VS or notepad, and go to File, Save As. In VS, there is a drop-down box on the Save button to select the encoding.

    Your "fileEncoding" attribute should match the file encoding of your souce files. You could try using fileEncoding="UTF-8" to see if it helps.

    Friday, March 7, 2008 1:55 PM
  • User-1878396931 posted

    Yes, I am using Visual Studio. I checked the file encoding and its 'Western Europe - Codepage 1252' so it should be right.

    Monday, March 10, 2008 3:18 AM
  • User-762694769 posted

    I just tried the following steps on my machine. My OS is Win2k3 English, but not sure whether that makes any difference.

    1. Create new C# web site in VS.

    2. In default.aspx, pasted the characters: å,ä,ö

    3. Save default.aspx as Western Europe - Codepage 1252.

    4. Open default.aspx.cs.

    5. Add Response.Write("å,ä,ö"); in Page_Load

    6. Save default.aspx.cs as Western Europe - Codepage 1252.

    7. In web.config specify <globalization requestEncoding="iso-8859-1" responseEncoding="iso-8859-1" fileEncoding="iso-8859-1" culture="sv-SE" uiCulture="sv-SE"/>

    8. Ctrl-F5. I see all 6 charcters.

    9. Publish to c:\website1_out . (I tried both updatable and non-updatable with same results)

    10. Create IIS virtual directory to point to c:\website1_out

    11. Browse the website, I see all 6 characters.

     

    Could you try the above steps in a new web site on your machine to see what happens?

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 11, 2008 2:17 PM
  • User-1878396931 posted

    Okey, I didn't try your steps, but I have done the very same thing in Win2k2 English, in another project, and then it works, it's only on Vista (English) i haven't got it to work. Could also mention that my collegue is using Vista (Swedish) and for him its working on the same project!

    Wednesday, March 12, 2008 3:59 AM