Skip to content

Escape C1 control characters with Unicode escapes - #15726

Merged
josevalim merged 1 commit into
elixir-lang:mainfrom
mnnekrashevich:fix-c1-control-character-escaping
Aug 9, 2026
Merged

Escape C1 control characters with Unicode escapes#15726
josevalim merged 1 commit into
elixir-lang:mainfrom
mnnekrashevich:fix-c1-control-character-escaping

Conversation

@mnnekrashevich

Copy link
Copy Markdown
Contributor

C1 control characters (U+0080–U+009F) were escaped using \xNN.
Because \xNN represents a raw byte, converting valid UTF-8 strings with
Macro.to_string/1 could change their encoding.

For example, U+0090 (<<0xC2, 0x90>>) was rendered as "\x90" and evaluated
back to the invalid UTF-8 byte <<0x90>>.

This change uses \u00NN for C1 control characters while retaining \xNN
for ASCII control bytes. It also adds a regression test covering the complete
U+0080–U+009F range.

Tests:

  • make format
  • bin/elixir lib/elixir/test/elixir/macro_test.exs
  • make test_stdlib
  • bin/elixir lib/elixir/test/elixir/system_test.exs

Assisted-by: Codex:GPT-5

Assisted-by: Codex:GPT-5
Signed-off-by: Mikhail Nekrashevich <mn.nekrashevich@yandex.ru>
@Inflyser

Inflyser commented Aug 8, 2026

Copy link
Copy Markdown

It's divine! You nailed it, bro!

@josevalim
josevalim merged commit 44085d4 into elixir-lang:main Aug 9, 2026
15 checks passed
@josevalim

Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants