The Wire · Showcase
ELIXIR FIXES UTF-8 CORRUPTION IN MACRO.TO_STRING, ECTO CUTS COMPILE DEPS
By RepoJournal · Filed · About Elixir & Phoenix
A critical fix landed for Elixir's string handling that was silently corrupting UTF-8 sequences when converting C1 control characters, while Ecto shipped a change that trims unnecessary compile-time dependencies from schema derivations.
Elixir merged a patch that rewrites how C1 control characters (U+0080 to U+009F) are escaped in `Macro.to_string/1` [1]. The old approach using `\xNN` for bytes could transform valid UTF-8 into invalid sequences on round-trip: U+0090 became `"\x90"` and evaluated back to the corrupt byte `<<0x90>>` instead of the original UTF-8 pair `<<0xC2, 0x90>>` [2]. The fix switches to `\u00NN` Unicode escapes for the C1 range while preserving `\xNN` for ASCII control bytes, with regression tests covering the full range. On the Ecto side, a PR merged that reorders conditional checks in schema compilation to avoid pulling in compile-time dependencies when reading `@derive` attributes unless redacted fields actually exist [3][4]. This cuts transitive compile coupling in projects that use protocols with module options.
One email a day. Unsubscribe in one click.
Keep up with Elixir & Phoenix in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.
One email a day. Unsubscribe in one click. Read a past issue →
Action items
- → Review any schemas using @derive with protocol options; test recompilation times after upgrade elixir-ecto/ecto [plan]
- → Update Elixir and verify string handling in systems that process control characters or binary data elixir-lang/elixir [plan]
References
- [1] Escape C1 control characters with Unicode escapes ↗ elixir-lang/elixir
- [2] Escape C1 control characters with Unicode escapes (#15726) elixir-lang/elixir
- [3] avoid compile-time dependency on modules named in derive ↗ elixir-ecto/ecto
- [4] Avoid compile-time dependency on modules named in derive (#4779) elixir-ecto/ecto