Skip to content

Commit

Permalink
Encode string escape chars with code formatting (dotnet#6261)
Browse files Browse the repository at this point in the history
* Encode string escape chars with code formatting

This makes it a bit more clear how to use them.

* Fix up statement of result
  • Loading branch information
cartermp authored Jul 2, 2018
1 parent 2bb54ed commit fb0e4ab
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions docs/fsharp/language-reference/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ String literals are delimited by the quotation mark (") character. The backslash

|Character|Escape sequence|
|---------|---------------|
|Backspace|\b|
|Newline|\n|
|Carriage return|\r|
|Tab|\t|
|Backslash|\\|
|Quotation mark|\"|
|Apostrophe|\'|
|Unicode character|\u*XXXX* or \U*XXXXXXXX* (where *X* indicates a hexadecimal digit)|
|Backspace|`\b`|
|Newline|`\n`|
|Carriage return|`\r`|
|Tab|`\t`|
|Backslash|`\\`|
|Quotation mark|`\"`|
|Apostrophe|`\'`|
|Unicode character|`\uXXXX` or `\UXXXX` (where `X` indicates a hexadecimal digit)|

If preceded by the @ symbol, the literal is a verbatim string. This means that any escape sequences are ignored, except that two quotation mark characters are interpreted as one quotation mark character.

Expand All @@ -36,7 +36,7 @@ let xmlFragment1 = @"<book author=""Milton, John"" title=""Paradise Lost"">"
let xmlFragment2 = """<book author="Milton, John" title="Paradise Lost">"""
```

In code, strings that have line breaks are accepted and the line breaks are interpreted literally as newlines, unless a backslash character is the last character before the line break. Leading whitespace on the next line is ignored when the backslash character is used. The following code produces a string `str1` that has value `"abc\n def"` and a string `str2` that has value `"abcdef"`.
In code, strings that have line breaks are accepted and the line breaks are interpreted literally as newlines, unless a backslash character is the last character before the line break. Leading whitespace on the next line is ignored when the backslash character is used. The following code produces a string `str1` that has value `"abc\ndef"` and a string `str2` that has value `"abcdef"`.

[!code-fsharp[Main](../../../samples/snippets/fsharp/lang-ref-1/snippet1001.fs)]

Expand Down

0 comments on commit fb0e4ab

Please sign in to comment.