2

On this boring Monday night, I noticed that Stack Exchange has omitted the character encoding meta element across their network, including our very own Stack Overflow.

Why should Stack Exchange care about character encoding?

If you use anything other than the most basic characters needed for English, people may not be able to read your text unless you say what character encoding you used.

For example, you may intend the text to look like this:

intended

but it may actually display like this:

displayed

Not only does inadequate encoding information spoil the readability of displayed text, but it may mean that your data cannot be found by a search, or reliably processed in a number of other ways.

With a global user base and questions that may include a-typical characters, this is potential for a wide-spread issue. Moreover, a generalized search investigation indicates that there are over 45,600 questions existing on Stack Overflow alone that could be affected by an omission of the character encoding.

In addition, forgoing the character encoding produces a warning on W3C's Markup Validation Service for StackOverflow.com, a sourly disappointing footnote on an otherwise valid page.

What's the solution?

This issue can be resolved through the simple inclusion of <meta charset="UTF-8"> within the first 512 bytes of the page.

2 Answers 2

5

There are (at least) three ways to indicate to a browser the character encoding:

  • HTTP headers: Content-Type:text/html; charset=utf-8

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

  • Shiny new meta charset <meta charset="utf-8" />

StackExchange already uses HTTP headers, which are the preferred method if available.

From Dive into HTML5: Character Encoding:

The HTTP header is the preferred method, and it overrides the <meta> tag if present.

I'm not sure why W3C is whinging about it, but they shouldn't.

2
  • 2
    The validator isn't actually complaining (not a warning or error) - it's just noting that the absence might cause problems if the page is separated from the tender loving care of its server. Which isn't particularly concerning.
    – Shog9
    Commented Jan 8, 2013 at 3:30
  • 1
    @Shog9: good tools that separate HTML pages from the tender care of their servers should (IMHO) transfer any relevant HTTP headers into equivalent <meta> tags. Commented Jan 8, 2013 at 8:55
1

It's specified in the response headers:

encoding specified in header

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .