Closed Confusion closed 9 years ago
A wrap-default-charset
middleware may be useful, one that adds a charset if none is specified. The Ring-Headers library is probably the most suitable place for this. Ring-Defaults leverages existing libraries; by design it doesn't introduce any of its own middleware.
When using ring and ring-defaults to serve static html, Firefox complains in its console that
w3 suggests that utf-8 is a reasonable default. I also interpret their comments there, and on linked pages, as saying that specifying utf-8 is better than defaulting to iso-8859-1 (which the absence of a charset implies), as utf-8 is more likely to be correct in more cases.
Currently everyone using ring, even with defaults, has to set the charset, even though it will be utf-8 in the majority of cases. Would it be an improvement for ring users if ring-defaults included a middleware that appends
;charset=utf-8
to all text-based content-types (text/*, application/json, ...), when no charset has been added to the response yet?