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

alexmiller00:08:21

\312 is not a thing

alexmiller00:08:42

oh, in a string that should be unicode

jaihindhreddy00:08:08

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

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

alexmiller00:08:46

actually, that is octal you're seeing

alexmiller00:08:56

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

andy.fingerhut00:08:37

In the section "Strings" then "Create"

alexmiller00:08:51

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

alexmiller00:08:09

maybe that's expected

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?

alexmiller00:08:09

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

alexmiller00:08:43

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

alexmiller00:08:55

or I should say expanded

andy.fingerhut00:08:17

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

alexmiller00:08:29

yes, per revision

alexmiller00:08:59

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

alexmiller00:08:21

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

alexmiller00: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?