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"
?
\312 is not a thing
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]"
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
actually, that is octal you're seeing
user=> \o312
\Ê
user=> "\312"
"Ê"
The Clojure cheatsheet might actually be complete here: https://jafingerhut.github.io/cheatsheet/clojuredocs/cheatsheet-tiptip-cdocs-summary.html
In the section "Strings" then "Create"
but "\o312"
doesn't work, which is the weird part?
maybe that's expected
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?
I guess the reader page just says "standard java escape characters are supported" and the rest refers to chars
yeah
of course, the Java standard has changed since that was written :)
or I should say expanded
Is there a changelog.md for changes to the Java spec? 🙂
yes, per revision
like http://cr.openjdk.java.net/~iris/se/12/spec/fr/java-se-12-fr-spec/java-se-12-annex-3.html
https://docs.oracle.com/javase/specs/jls/se12/html/jls-3.html#jls-3.10.6 is the relevant latest java string escapes
I think that's all the same as forever though and should work in Clojure
I was think of the number format changes (like 1_000)
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?