Some Bits: Nelson's log

Mojibake in RSS feeds for Feedly

I took over Feditrends, which has an RSS 2.0 feed. The feed’s contents are in UTF-8. Feedly doesn’t display them correctly, interpreting the typographical punctuation as ISO-8859-1 nonsense instead.

That mess is supposed to be quotation marks: U+201C “ at the start.

The underlying problem is that neither the feed document nor the Apache2 server specify the encoding. And in the absence Feedly is guessing ISO-8859-1. Odd guess in 2024! This may also be a problem for JSON feeds. Real weird if so, JSON’s default is UTF-8 as is jsonfeed’s recommendation.

The fix I just deployed now for the RSS feed is to add <?xml version="1.0" encoding="utf-8"?> to the start of the RSS feed document. I don’t know if this works yet. Two years ago I discovered it’s hard to test RSS feeds, there’s very few clients to use. And ones like Feedly I can’t force to refresh and display new. So instead I’ll just wait a day and see. Update I think it worked; the U+2019 in this headline displays in Feedly properly as “Ford’s” and looks like a curly apostrophe.

The other fix would be to get the HTTP server to specify the encoding. I suspect that’s what the old server was doing and I introduced a bug when I took over the product. Right now my server is sending Content-Type: application/xml without specifying the byte encoding. Adding a charset=utf-8 to that would be a good idea. But that configuration turns out to be slightly difficult in Apache2. I’ve already got AddDefaultCharset utf-8 in the config but that doesn’t really apply everywhere. Some random LLM recommends adding this to my config:

<FilesMatch "\.xml$">
Header set Content-Type "application/xml; charset=utf-8"
</FilesMatch>

That looks plausible. But I prefer the RSS document itself be self-describing. I’d set it in the HTTP transport too but I hate messing with Apache configs.

Two observations

Apache2 is really not a good web server anymore. It’s never modernized. So configuring Let’s Encrypt is a real mess (smoothed over by certbot). It has strange defaults for a world before UTF-8 and HTTPS everywhere. It’s possible it’ll never support HTTP/3. I only use it because I’ve been using it for, what, 29 years now? It’d be a Project to migrate my existing stuff over. I like Caddy these days as a modern simpler replacement although it lacks CGI support. (Don’t laugh, it’s still useful!).

The word “encoding” is ambiguous. I often say things like “that document is encoded in UTF-8”. But people also say “the feed is encoded in RSS 2.0” or “RSS is encoded in XML”. So many layers of encoding. “Charset” seems to be the better term to mean “is this ISO-8859-1 or UTF-8?” But that doesn’t feel quite right either. Surely Unicode is the set of characters, and UTF-8 is the encoding of that into bytes? Huh.