Unespected raw string behaviour

According to the String Interpolation Overview

The raw interpolator is similar to the s interpolator except that it performs no escaping of literals within the string.

But experimenting on the REPL I got:

scala> """\textbf{text}"""
val res8: String = \textbf{text}

scala> """\rextbf{text}"""
val res9: String = \rextbf{text}

scala> """\underline{text}"""
            ^
       error: invalid unicode escape at index 2 of \underline{text}

My questions are:

  1. why is\u escaped unlike \t or \r ?
  2. how can I correct the error?

Thank you for your time. Enjoy the week-end.
Guido

\u is still treated as an escape for historical reasons. Unicode escapes used to be pre-processed in the scanner. That was changed in 2.13.2, which as a point release maintained backwards compatibility with the earlier behaviour in multi line strings.

Thank you for the reply.
I’m using 2.13.4, so, if I got you correctly, this issue shouldn’ t occur, should it?
What about question nr. 2? Any idea?
Thank you again.
Guido

Martijn just meant that the implementation was changed, but the broken behavior regarding \u could not be fixed because of semantic versioning. It might be fixed in 3.x / Dotty.

How about:

"\\underline{text}"
2 Likes