# Raw / triple-quoted strings don't preserve the line separator of the system

**URL:** <https://discuss.kotlinlang.org/t/raw-triple-quoted-strings-dont-preserve-the-line-separator-of-the-system/26213>\
**Category:** Uncategorized\
**Created:** [January 13, 2023, 7:37pm UTC](https://discuss.kotlinlang.org/t/raw-triple-quoted-strings-dont-preserve-the-line-separator-of-the-system/26213 "2023-01-13T19:37:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![determinant](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@determinant](https://discuss.kotlinlang.org/u/determinant)\
**Post date:** [January 13, 2023, 7:37pm UTC](https://discuss.kotlinlang.org/t/raw-triple-quoted-strings-dont-preserve-the-line-separator-of-the-system/26213/1 "2023-01-13T19:37:41Z")

</div>

It seems like triple-quoted strings don’t preserve the line separator of the system.

For example, on Windows this:

```auto
"""
   -first line
   -second line
""".trimIndent()

```

compiles to

```auto
"-first line\n-secondline"

```

instead of

```auto
"-first line\r\n-second line"

```

Is this by design? Is there any official documentation about line separators in triple-quoted strings?

---

<div class="post-metadata">

**Author:** ![elizarov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/elizarov/32/2164_2.png) [@elizarov](https://discuss.kotlinlang.org/u/elizarov)\
**Post date:** [January 17, 2023, 11:16am UTC](https://discuss.kotlinlang.org/t/raw-triple-quoted-strings-dont-preserve-the-line-separator-of-the-system/26213/2 "2023-01-17T11:16:43Z")

</div>

Yes. It is so by design. There is a key requirement that behavior of the code should not depend on the platform it was compiled on. If you want platform line separators, I’d suggest:

```auto
"""
   -first line
   -second line
""".trimIndent().replace("\n", System.lineSeparator())

```

---

<div class="post-metadata">

**Author:** ![determinant](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@determinant](https://discuss.kotlinlang.org/u/determinant)\
**Post date:** [January 18, 2023, 7:01pm UTC](https://discuss.kotlinlang.org/t/raw-triple-quoted-strings-dont-preserve-the-line-separator-of-the-system/26213/3 "2023-01-18T19:01:06Z")

</div>

That makes sense thank you.

I recommend adding a short comment about line separators in this section of the docs:

> **[Strings | Kotlin](https://kotlinlang.org/docs/strings.html)**

We initially assumed that there was a problem with our environment setup so it took a while to narrow in on the root cause.

---

<div class="post-metadata">

**Author:** ![elizarov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/elizarov/32/2164_2.png) [@elizarov](https://discuss.kotlinlang.org/u/elizarov)\
**Post date:** [January 18, 2023, 7:17pm UTC](https://discuss.kotlinlang.org/t/raw-triple-quoted-strings-dont-preserve-the-line-separator-of-the-system/26213/4 "2023-01-18T19:17:40Z")

</div>

I’ve created [KT-56021](https://youtrack.jetbrains.com/issue/KT-56021) Docs: Mention that multiline strings always use NL separators regardless of the platform.
