Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the default encoding to UTF-8 for Apache

I am using a hosting company and it will list the files in a directory if the file index.html is not there. It uses ISO 8859-1 as the default encoding.

If the server is Apache, is there a way to set UTF-8 as the default instead?

I found out that it is actually using a DOCTYPE of HTML 3.2 and then there is not charset at all... so it is not setting any encoding. But is there a way to change it to use UTF-8?

like image 671
nonopolarity Avatar asked Oct 11 '22 10:10

nonopolarity


People also ask

How do I change system encoding?

Open Windows Control Panel -> Region. Go to the Administrative tab and click Change system locale... Remove the check mark next to Beta: Use UTF-8 for worldwide language support. Click OK and restart your computer.

What is a Codepoint in UTF-8?

Code points allow abstraction from the term character and are the atomic unit of storage of information in an encoding. Most code points represent a single character, but some represent information such as formatting. UTF-8 is a “variable-width” encoding standard.

Why is Java UTF-16?

The native character encoding of the Java programming language is UTF-16. A charset in the Java platform therefore defines a mapping between sequences of sixteen-bit UTF-16 code units (that is, sequences of chars) and sequences of bytes.


2 Answers

In httpd.conf add (or change if it's already there):

AddDefaultCharset utf-8
like image 188
MartinodF Avatar answered Oct 13 '22 23:10

MartinodF


Add this to your .htaccess:

IndexOptions +Charset=UTF-8

Or, if you have administrator rights, you could set it globally by editing httpd.conf and adding:

AddDefaultCharset UTF-8

(You can use AddDefaultCharset in .htaccess too, but it won’t affect Apache-generated directory listings that way.)

like image 59
Mathias Bynens Avatar answered Oct 13 '22 22:10

Mathias Bynens