Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Why am I getting the error

Syntax::sntunc: Unicode longname in the string is unterminated.

from the following?

astroSymbol[name_String] := ToString[ToExpression["\[" <> name <> "]"]] <> "" ;

Is there something I need to do to wrap the escape sequence to avoid this error?

You have to escape the slash: "\\[" –  Leonid Shifrin Nov 14 '12 at 15:15
That's the answer. I'm surprised it works at all without the escape (it generates the expected string). –  raxacoricofallapatorius Nov 14 '12 at 15:18
You can write an answer to your own question, now. :) –  J. M. Nov 14 '12 at 16:07

1 Answer 1

up vote 3 down vote accepted

To include a backslash in a string, you need to escape it, like so:

"\\[" <> name <> "]"

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .