Wednesday, August 22, 2018

html - Can I make browsers choose UTF-8 for viewing source code?

I put up some source code files for viewing on the web. The problem is, browsers tend to not understand that these files are in UTF-8, and I wonder if there's anything I can do about that. (I'm sure some browsers use UTF-8 per default, but Safari at least doesn't. I have to go into the View menu and choose the encoding manually to make it look right.)


My set of webpages is here, with several Python files and one C file: fgcode.avadeaux.net. I tried putting a charset="UTF-8" attribute in the a elements in the , but that doesn't seem to help. The Python files declare the charset in a comment on the top line, but the browser ignores that as well (which is no surprise, it's not a Python source code browser after all).


I don't have much control over the web server, it's run by my ISP and I just put the files there. But I'd still be interested to know if this problem has a web server configuration solution.


Solution: solved, as per links provided, by adding an .htaccess file with the following content:


AddDefaultCharset UTF-8
AddCharset UTF-8 .py
AddCharset UTF-8 .c

Only the first line wasn't enough in my case.

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...