I'm migrating a web system that now works on windows server 2003 IIS 6, to IIS 7.5 on windows 2008 server This system generates javascript files with accented characters in ANSI (Portuguese - Brazil). These javascripts shows for example alert messages. In IIS 6 I have no problem with that, but now using IIS 7.5 if those files are not in UTF-8, the accented characters do not appear correctly. Do we have any way to force these files, even in ANSI, to be processed by IIS 7.5 as UTF-8 ? Thank you ! Cheers Xcarpa


I think the best solution is not to force IIS to deliver the files as UTF-8, but to force IIS to tell the world they are ANSI encoded. Otherwise, it would be necessary an ISAPI filter to perform on the fly conversion of the ANSI encoded files to UTF-8, which may cost a lot of CPU cycles, depending on the number of JavaScript files and the frequency they are accessed.

I recommend adjusting the MIME types configuration on IIS, to force JavaScript files to be delivered as ANSI. To do that, use IIS Manager, go to the server level, click on the MIME Types button, look for ".js" extension and add "; charset=Windows-1252" (without quotes) to the end of the MIME type definition. Again, don't replace the definition, just add the text between quotes and you should fix the problem.


As Jose pointed out, I would not let IIS convert these resources on the fly. Instead, you might want to convert the actual JavaScript files to UTF-8 with a text editor or a command line tool like recode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.