diff --git a/scalameta/tokenizers/shared/src/main/scala/scala/meta/internal/tokenizers/LegacyScanner.scala b/scalameta/tokenizers/shared/src/main/scala/scala/meta/internal/tokenizers/LegacyScanner.scala index 352a71ca1b..db29ef86bc 100644 --- a/scalameta/tokenizers/shared/src/main/scala/scala/meta/internal/tokenizers/LegacyScanner.scala +++ b/scalameta/tokenizers/shared/src/main/scala/scala/meta/internal/tokenizers/LegacyScanner.scala @@ -233,8 +233,10 @@ class LegacyScanner(input: Input, dialect: Dialect) { } @inline - def reportIllegalCharacter(): Unit = curr - .setInvalidToken(s"illegal character '\\u${"%04x".format(ch)}'") + def reportIllegalCharacter(): Unit = { + val output = "\\u" + Integer.toHexString(ch | 0x10000).substring(1); + curr.setInvalidToken(s"illegal character '$output'") + } (ch: @switch) match { case ' ' =>