How can I force a particular character encoding (charset) across my site?


If you are writing in a different language, or want to use certain characters that are not showing up on your site, you can adjust the character encoding.

Character encodings, also known as charsets, tell computers and browsers how to interpret the information that is on your website.  If you are using a non-Latin-based language, such as Chinese or Arabic, setting the character encoding correctly ensures that your visitors can see your site as you intended.

You can set the character encoding through a META tag in your HTML, like so:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Which is effective for a single page that is in one language while the rest of your site is another.

If you want to change the character encoding for your entire site, you can do this through an .htaccess file.

To change the charset across the site:

  1. Create or open your .htaccess file in your text editor
  2. Add the following line:

AddCharset [character set] [file extension]
where [character set] is replaced by the charset you wish to use and [file extension] is all the files you want to read that character encoding (such as .html, .css, .php, etc.)

  1. Save your .htaccess file
  2. Upload to your site

This will change the character encoding for all the pages you have specified.



Article ID: 475
Created On: Tue, Mar 17, 2015 at 3:35 PM
Last Updated On: Thu, Apr 23, 2015 at 12:47 PM

Online URL: https://www.heartinternet.uk/support/article/how-can-i-force-a-particular-character-encoding-charset-across-my-site.html