Fork me on GitHub

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


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

Alex Miller (Clojure team)00:08:42

oh, in a string that should be unicode


: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"


In the section "Strings" then "Create"

Alex Miller (Clojure team)00:08:51

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


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


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


Is there a 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)


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