clojure-dev

Issues: https://clojure.atlassian.net/browse/CLJ | Guide: https://insideclojure.org/2015/05/01/contributing-clojure/
jaihindhreddy 2019-08-31T00:21:28.014900Z

Where can I find an exhaustive list of escape sequences in Clojure string literals? Is this different in ClojureScript?

jaihindhreddy 2019-08-31T00:22:02.015500Z

For example, what does this mean: "\312"?

alexmiller 2019-08-31T00:22:55.015900Z

https://clojure.org/reference/reader

alexmiller 2019-08-31T00:23:21.016200Z

\312 is not a thing

alexmiller 2019-08-31T00:23:42.016500Z

oh, in a string that should be unicode

jaihindhreddy 2019-08-31T00:25:08.017400Z

:thinking_face:, But I thought unicode escapes are written this way: "\uXXXX", where X is #"[\da-fA-F]"

alexmiller 2019-08-31T00:28:42.018700Z

I'm honestly not sure what's going on there - you're getting some kind of encoding, but does not seem to be octal or hex

alexmiller 2019-08-31T00:30:46.019100Z

actually, that is octal you're seeing

alexmiller 2019-08-31T00:30:56.019300Z

user=> \o312
\Ê
user=> "\312"
"Ê"

2019-08-31T00:32:17.020100Z

The Clojure cheatsheet might actually be complete here: https://jafingerhut.github.io/cheatsheet/clojuredocs/cheatsheet-tiptip-cdocs-summary.html

2019-08-31T00:32:37.020400Z

In the section "Strings" then "Create"

alexmiller 2019-08-31T00:32:51.020800Z

but "\o312" doesn't work, which is the weird part?

alexmiller 2019-08-31T00:33:09.021200Z

maybe that's expected

2019-08-31T00:34:44.021600Z

I think that is expected, even if it doesn't make it terribly easy to remember 🙂

2019-08-31T00:35:06.022400Z

Strings use Java syntax, character literals are distinct to Clojure, I think?

alexmiller 2019-08-31T00:35:09.022600Z

I guess the reader page just says "standard java escape characters are supported" and the rest refers to chars

alexmiller 2019-08-31T00:35:11.022800Z

yeah

alexmiller 2019-08-31T00:35:43.023200Z

of course, the Java standard has changed since that was written :)

alexmiller 2019-08-31T00:35:55.023400Z

or I should say expanded

2019-08-31T00:38:17.023800Z

Is there a changelog.md for changes to the Java spec? 🙂

alexmiller 2019-08-31T00:41:29.024200Z

yes, per revision

alexmiller 2019-08-31T00:42:41.024700Z

https://docs.oracle.com/javase/specs/jls/se12/html/jls-3.html#jls-3.10.6 is the relevant latest java string escapes

alexmiller 2019-08-31T00:42:59.025100Z

I think that's all the same as forever though and should work in Clojure

alexmiller 2019-08-31T00:43:21.025600Z

I was think of the number format changes (like 1_000)

alexmiller 2019-08-31T00:44:26.026200Z

which has not been added to Clojure (and might even be problematic given our support for _ as a symbol)

dominicm 2019-08-31T06:01:23.026800Z

Shouldn't be problematic, because symbols can't start with numbers?