Fork me on GitHub
#clojure-dev
<
2019-08-31
>
jaihindhreddy00:08:28

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

jaihindhreddy00:08:02

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

Alex Miller (Clojure team)00:08:42

oh, in a string that should be unicode

jaihindhreddy00:08:08

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

Alex Miller (Clojure team)00:08:42

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

Alex Miller (Clojure team)00:08:46

actually, that is octal you're seeing

Alex Miller (Clojure team)00:08:56

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

andy.fingerhut00:08:37

In the section "Strings" then "Create"

Alex Miller (Clojure team)00:08:51

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

andy.fingerhut00:08:44

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

andy.fingerhut00:08:06

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

Alex Miller (Clojure team)00:08:09

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

Alex Miller (Clojure team)00:08:43

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

Alex Miller (Clojure team)00:08:55

or I should say expanded

andy.fingerhut00:08:17

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

Alex Miller (Clojure team)00:08:59

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

Alex Miller (Clojure team)00:08:21

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

Alex Miller (Clojure team)00:08:26

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

dominicm06:08:23

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