Skip to main content

string_text

Function string_text 

Source
pub fn string_text(text: &str) -> String
Expand description

Escape a string for a Kotlin string literal.

Kotlin’s escapes are \t, \b, \n, \r, \', \", \\, \$ and \uXXXX (Kotlin language specification, “String literals”); there is no \0, as in Zig, so a NUL goes out \\u0000. $ is escaped everywhere, not only before { or a letter: Kotlin’s string template only ever reads $name or ${expr}, but escaping the character unconditionally means this function never has to look ahead at what follows a $ in the source text to decide.