mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Fix unicode escape sequences in Str docs
Unicode characters are escaped like \u(00) instead of \{0x00}. Tested
that this is the same for the repl and the hello world example
`Stdout.line "Hello,\u(0A)World!"`.
Found the correct syntax here:
304768569
This commit is contained in:
parent
773efc74aa
commit
550b22c633
1 changed files with 6 additions and 6 deletions
|
@ -37,17 +37,17 @@
|
|||
## The `"\n"` in the middle will insert a line break into this string. There are
|
||||
## other ways of getting a line break in there, but `"\n"` is the most common.
|
||||
##
|
||||
## Another way you could insert a newlines is by writing `\u{0x0A}` instead of `\n`.
|
||||
## Another way you could insert a newlines is by writing `\u(0A)` instead of `\n`.
|
||||
## That would result in the same string, because the `\u` escape sequence inserts
|
||||
## [Unicode code points](https://unicode.org/glossary/#code_point) directly into
|
||||
## the string. The Unicode code point 10 is a newline, and 10 is `0A` in hexadecimal.
|
||||
## `0x0A` is a Roc hexadecimal literal, and `\u` escape sequences are always
|
||||
## followed by a hexadecimal literal inside `{` and `}` like this.
|
||||
## `\u` escape sequences are always followed by a hexadecimal number inside `(` and `)`
|
||||
## like this.
|
||||
##
|
||||
## As another example, `"R\u{0x6F}c"` is the same string as `"Roc"`, because
|
||||
## `"\u{0x6F}"` corresponds to the Unicode code point for lowercase `o`. If you
|
||||
## As another example, `"R\u(6F)c"` is the same string as `"Roc"`, because
|
||||
## `"\u(6F)"` corresponds to the Unicode code point for lowercase `o`. If you
|
||||
## want to [spice things up a bit](https://en.wikipedia.org/wiki/Metal_umlaut),
|
||||
## you can write `"R\u{0xF6}c"` as an alternative way to get the string `"Röc"\.
|
||||
## you can write `"R\u(F6)c"` as an alternative way to get the string `"Röc"\.
|
||||
##
|
||||
## Roc strings also support these escape sequences:
|
||||
##
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue