From b0e9b4eba3bf2c89af06ced5623c8570232815f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20Bregu=C3=AAz?= Date: Sun, 11 Oct 2026 18:28:34 -0300 Subject: [PATCH] fix: read every file as UTF-8 when the build machine has no UTF-8 locale Cloudflare Pages builds cannot set en_US.UTF-8, so Ruby defaulted to US-ASCII. `encoding:` in _config.yml covers pages only; _data YAML is read with Ruby's default, and kramdown failed on the accented pt-BR resources added in #34 ("The source text contains invalid characters for the used encoding US-ASCII"). Plugins load before the site is read, so setting the default encodings there fixes every file. Co-Authored-By: Claude Opus 5.5 (1M context) --- _plugins/000_utf8_encoding.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 _plugins/000_utf8_encoding.rb diff --git a/_plugins/000_utf8_encoding.rb b/_plugins/000_utf8_encoding.rb new file mode 100644 index 0000000..12fc990 --- /dev/null +++ b/_plugins/000_utf8_encoding.rb @@ -0,0 +1,5 @@ +# Build environments without a UTF-8 locale (Cloudflare Pages: "cannot change locale (en_US.UTF-8)") make Ruby read +# files as US-ASCII. `encoding:` in _config.yml covers pages only; _data YAML is read with Ruby's default, and +# kramdown then fails on accented pt-BR text. Plugins load before the site is read, so this fixes it for every file. +Encoding.default_external = Encoding::UTF_8 +Encoding.default_internal = Encoding::UTF_8