encodingvbscriptasp-classicmicrosoft-expression-web

preserve encoding for included files


I have used UTF-8 encoding and ASP classic with vbscript as default scripting language in my website. I have separated files to smaller parts for better management.

I always use this trick in first line of separated files to preserve UTF-8 encoding while saving files elsewhere the language characters are converted to weird characters.

mainfile.asp

    <html>
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    </head>
    <body>
    <!--#include file="sub.asp"--->
    </body>
    </html>

sub.asp

  <%if 1=2 then%>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  <%end if%>
  this is some characters in other language:
  تست متن به زبان فارسی

This trick works good for offline saving and also works good when the page is running on the server because these Extra lines are omitted (because the condition is always false!):

Is there a better way to preserve encoding in separated files?

I use Microsoft expression web for editing files.


Solution

  • I use Textpad to ensure that all main files and includes are saved in UTF-8 encoding. Just hit 'Save As' and set the encoding dropdown on the dialog to the one you want.

    Keep the meta tag as well because that is still necessary.