0

I've switched hosts and somehow on all my HTML files which contain the pound sign is replaces with an A in front: £. Is there a way to overcome this problem without adding

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

on every HTML page?

Thomas893
  • 31
  • 1
  • 1
  • 4

1 Answers1

0

You have various alternative ways to overcome the problem, including any one of these:

  • In .htaccess as you asked: insert the line "AddDefaultCharset utf-8" or follow further advice from W3C or further advice from askapache.com
  • Insert the HTML 5 doctype "<!DOCTYPE html>" at the beginning of each HTML page, thus causing the browser to interpret the default character encoding to be UTF-8 instead of ISO-8859-1.
  • Store your HTML using character encoding ISO-8859-1, so that the pound sign is stored as one byte. Currently your HTML would appear to be stored using character encoding UTF-8, so that the pound sign is stored as two bytes. Here is one way to store a copy of a UTF-8 file as ISO-8859-1: iconv --from-code=UTF-8 --to-code=ISO-8859-1 inputfile.html > outputfile.html
  • Store your HTML using 7-bit (ASCII) characters, with the pound sign encoded as an XML numeric character entity &#163; or (hexadecimal) &#xA3; or the HTML named character entity &pound;
Community
  • 1
  • 1
minopret
  • 4,726
  • 21
  • 34
  • for some reason the htaccess method you stated does not work, thanks for your efforts though. – Thomas893 Feb 17 '13 at 23:09
  • 1
    @Thomas893, post a URL, or at least show the exact content of the `.htaccess` file. Check local instructions or website admin to find out whether the server settings allow per-directory `.htaccess` files to take effect. – Jukka K. Korpela Feb 18 '13 at 06:29
  • 1
    @minopret, is there evidence of browsers actually using the doctype string when determining the encoding? By the HTML5 CR, browsers should apply an algorithm that does not involve doctype and ultimately fall back to “an implementation-defined or user-specified default character encoding”. – Jukka K. Korpela Feb 18 '13 at 06:36
  • Great point, I'm not sure whether there is any experience of browsers actually using doctype to determine encoding. I would ask @JukkaK.Korpela :-) , or when he's not available, perhaps Peter-Paul Koch. I just tried it in Safari 6.0.2 and in fact it displayed the two symbols A-circumflex and pound despite the HTML5 doctype. I have stricken out that suggestion. – minopret Feb 18 '13 at 12:51