Incorrect handle of unicode escapes in triple-quoted string
See original GitHub issueCompiler version
3.0.0-RC1
Minimized code
object Bar{
def main(args: Array[String]): Unit = {
println(""""\\\uCAFE"""".getBytes.toList)
}
}
Output
This is what it prints in 3.0.0-RC1
List(34, 92, 92, 92, 117, 67, 65, 70, 69, 34)
Expectation
This is what it prints in 2.13.4 and 2.12.13
List(34, 92, 92, -20, -85, -66, 34)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Unicode escapes in triple quoted strings are deprecated, use ...
Unicode escapes in triple quoted strings are deprecated, use the literal character instead : r/scala.
Read more >(unicode error)" occur when raw string is in triple quotes ...
I have tried moving the triple quotes to align with various parts of the code but nothing has worked so far. Because \N...
Read more >ASCII and Unicode quotation marks
If you can use Unicode characters, nice directional quotation marks are available in the form of characters U+2018, U+2019, U+201C, and U+201D (as...
Read more >How to Handle the Unclosed String Literal Error in Java - Rollbar
Python unclosed string literal error refers to the Java compiler failing to interpret a string literal due to the missing of a double...
Read more >Python Strings | Python Education - Google Developers
Backslash escapes work the usual way within both single and double quoted literals -- e.g. \n \' \". A double quoted string literal...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
raw""""\\${'\uCAFE'}""""
also works2.13 emits a deprecation warning for the escape in a triple quoted string, scala 3 doesn’t handle the escape anymore. I believe that behaviour follows the principle of least astonishment: Unicode escapes are treated as any other escape, that is to say, they’re escaped in single quoted strings, backquoted identifiers and char literals and by the
f
ands
interpolators.The three options that will work with any version are
For this particular string, those are respectively
""""\\쫾""""
,raw"$"\\${'\uCAFE'}$""
and"\"\\\\\uCAFE\""
Reference https://github.com/lampepfl/dotty/pull/8480 and https://github.com/scala/scala/pull/8282