You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by David Lane <da...@gmail.com> on 2010/12/12 19:57:52 UTC

[users@httpd] Add HTTP header charset from HTML meta tag?

Hello,

I'm looking for a way to handle a body of existing HTML which is encoded
inconsistently.  On the basis that the meta tag is likely to be correct, I'd
like to use that to set the HTTP content-type header's charset.  I have
Googled for solutions, and checked the module documents, and I don't see a
way to do what I have in mind.  I found a number of ways to set the header,
which seem to be "more correct" and would be fine in a better situation
(.htaccess files, changing file suffixes, etc.), but the tangle of existing
content, CMS, users and maintenance makes me lean toward a server-based
solution.  Did I miss something obvious?

David.

Re: [users@httpd] Add HTTP header charset from HTML meta tag?

Posted by David Lane <da...@gmail.com>.
On Sun, Dec 12, 2010 at 2:20 PM, Nick Kew <ni...@webthing.com> wrote:

>
> On 12 Dec 2010, at 18:57, David Lane wrote:
>
> > Hello,
> >
> > I'm looking for a way to handle a body of existing HTML which is encoded
> inconsistently.  On the basis that the meta tag is likely to be correct, I'd
> like to use that to set the HTTP content-type header's charset.  I have
> Googled for solutions, and checked the module documents, and I don't see a
> way to do what I have in mind.  I found a number of ways to set the header,
> which seem to be "more correct" and would be fine in a better situation
> (.htaccess files, changing file suffixes, etc.), but the tangle of existing
> content, CMS, users and maintenance makes me lean toward a server-based
> solution.  Did I miss something obvious?
>
> If it's too inconsistent to automate, there's no really good solution.
>
> mod_xml2enc nearly does what you want: it'll sniff the encoding from the
> <meta>
> if the server doesn't set charset.  If you just chop out the libxml2
> detection
> (xmlParseCharEncoding) it'll do exactly what you need.  Alternatively you
> can
> use it together with a libxml2-consumer module like mod_proxy_html, which
> both deals with the charset issue and offers explicit <meta http-equiv>
> support.
>
> --
> Nick Kew
> ---------------------------------------------------------------------
>
>
Hello Nick, I forgot to thank you for this.  The mod_proxy_html module does
do almost exactly what I want.  I'd rather keep the meta tag in place to
placate people concerned about the local file save issues, but other than
that, I'm golden.  Thanks.

Re: [users@httpd] Add HTTP header charset from HTML meta tag?

Posted by Nick Kew <ni...@webthing.com>.
On 12 Dec 2010, at 18:57, David Lane wrote:

> Hello,
> 
> I'm looking for a way to handle a body of existing HTML which is encoded inconsistently.  On the basis that the meta tag is likely to be correct, I'd like to use that to set the HTTP content-type header's charset.  I have Googled for solutions, and checked the module documents, and I don't see a way to do what I have in mind.  I found a number of ways to set the header, which seem to be "more correct" and would be fine in a better situation (.htaccess files, changing file suffixes, etc.), but the tangle of existing content, CMS, users and maintenance makes me lean toward a server-based solution.  Did I miss something obvious?

If it's too inconsistent to automate, there's no really good solution.

mod_xml2enc nearly does what you want: it'll sniff the encoding from the <meta>
if the server doesn't set charset.  If you just chop out the libxml2 detection
(xmlParseCharEncoding) it'll do exactly what you need.  Alternatively you can
use it together with a libxml2-consumer module like mod_proxy_html, which
both deals with the charset issue and offers explicit <meta http-equiv> support.

-- 
Nick Kew
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org