Kotlin - Form submission nature - Illegal escape: '\ f'

Kotlin

does not support escape "\f"

(feed feed character). So what's the correct path "\f"

from java

to Kotlin

?

Java:

String str = "\f"; // OK

      

Kotlin:

var str = "\f"  // Illegal escape: '\f'

      

Anyway, it looked like a mistake because Kotlin and Java should work well together.

+3


source to share


1 answer


Use unicode escape \u000C

. Kotlin doesn't support escape \f

.
It is not widely used. - actually I didn't understand what Java is \f

until I see your question.

I made a table in Java and kotlin escape sequence:



Escape type | kotlin | java
\ uXXXX yes yes
\ XXX no yes // this is Java octal escape.
\ t yes yes
\ b yes yes
\ n yes yes
\ r yes yes
\ f no yes
\ 'yes yes
\ "yes yes
\\ yes yes
\ $ yes no // Java just uses $

(Kotlin needs an escaped $ because string templates use $.)

+5


source







All Articles