Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webdoc information on Unicode string literals #935

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/src/reference-main-strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,25 @@ You can use the following backslash escapes for strings such as between the doub
* `\"`: double quote
* `\123`: Octal 123, etc. for `\000` up to `\377`
* `\x7f`: Hexadecimal 7f, etc. for `\x00` up to `\xff`
* `\u2766`, `\U00010877:`: Unicode literals. For technical reasons, you must supply four hex digits after `\u` and eight hex digits after `\U`.

<pre class="pre-highlight-in-pair">
<b>mlr repl</b>
</pre>
<pre class="pre-non-highlight-in-pair">
[mlr] "a\nb"
"a
b"

[mlr] "a\tb"
"a b"

[mlr] "a\x62c"
"abc"

[mlr] "\u2766\U00010877"
"❦𐡷"
</pre>

See also [https://en.wikipedia.org/wiki/Escape_sequences_in_C](https://en.wikipedia.org/wiki/Escape_sequences_in_C).

Expand Down
17 changes: 17 additions & 0 deletions docs/src/reference-main-strings.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,23 @@ You can use the following backslash escapes for strings such as between the doub
* `\"`: double quote
* `\123`: Octal 123, etc. for `\000` up to `\377`
* `\x7f`: Hexadecimal 7f, etc. for `\x00` up to `\xff`
* `\u2766`, `\U00010877:`: Unicode literals. For technical reasons, you must supply four hex digits after `\u` and eight hex digits after `\U`.

GENMD-CARDIFY-HIGHLIGHT-ONE
mlr repl
[mlr] "a\nb"
"a
b"

[mlr] "a\tb"
"a b"

[mlr] "a\x62c"
"abc"

[mlr] "\u2766\U00010877"
"❦𐡷"
GENMD-EOF

See also [https://en.wikipedia.org/wiki/Escape_sequences_in_C](https://en.wikipedia.org/wiki/Escape_sequences_in_C).

Expand Down
4 changes: 4 additions & 0 deletions internal/pkg/lib/unbackslash.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func UnbackslashStringLiteral(input string) string {
// } else {
// return input
// }
//
// ... and, given that desire, we don't a priori know how many digits in Unicode
// escape sequences -- so we *require* that people use four hex digits after \u
// and eight hex digits after \U.

var buffer bytes.Buffer

Expand Down
164 changes: 84 additions & 80 deletions internal/pkg/parsing/lexer/lexer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions internal/pkg/parsing/lexer/transitiontable.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions internal/pkg/parsing/mlr.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ _string_literal_element
| ( '\\' '[' ) | ( '\\' ']' )
| ( '\\' 'b' ) | ( '\\' 'f' )
| ( '\\' 'n' ) | ( '\\' 'r' )
| ( '\\' 't' )
| ( '\\' 'x' )
| ( '\\' 't' ) | ( '\\' 'x' ) | ( '\\' 'a' ) | ( '\\' 'v' )
| ( '\\' 'u' ) | ( '\\' 'U' )
| ( '\\' '.' )
| ( '\\' '*' )
Expand Down
8 changes: 4 additions & 4 deletions todo.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
=============================================================== RELEASES

* plan 6.1.0
? strptime
? inference
? datediff et al.
? strptime/882
? mlr join --left-fields a,b,c
o fmt/unfmt/regex doc
o FAQ/examples reorg
m strptime/strftime tabulate options
m unicode string literals
k unicode string literals
k natural sort order
k IANA-TSV w/ \{X}
k still need csv --lazy-quotes
Expand All @@ -23,8 +21,10 @@
k ?foo and ??foo @ repl help
k doc-improves
* plan 6.2.0
? datediff et al.
? rank
? YAML
? #908 inferencing options

================================================================
FEATURES
Expand Down