i'm trying set encoding .txt static files on iis 8.5 webserver. i've researched should add web.config file:
<system.webserver> <staticcontent> <remove fileextension=".txt" /> <mimemap fileextension=".txt" mimetype="text/html; charset=utf-8"/> </staticcontent> </system.webserver>
while seems work page open .txt files in chrome utf-8 seems strip line feeds , 1 big block of non stop text (code).
on other hand remove lines chrome opens page windows-1252 encoding (which problem because extended characters in text file encoded in utf-8 don't show up). if manually change encoding on page through chrome settings utf-8 appears including line feeds.
what doing wrong, why line feeds being stripped when set encoding in web.config file?
okay figured out (accidentally while crawling web in obscure msdn page).
the issue way mime type defined. when using "text/html" strips out carriage returns text files (i guess it's unix vs dos , html compatibility).
anyways preserve carriage feed in windows/dos style text files , change default encoding utf-8 static .txt files, use following:
<system.webserver> <staticcontent> <remove fileextension=".txt" /> <mimemap fileextension=".txt" mimetype="text/plain; charset=utf-8"/> </staticcontent> </system.webserver>
notice changed "text/html" "text/plain" , seemed make difference.
i got clue msdn website: adding static content mime mappings
Comments
Post a Comment