This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / The Mathematica Book / Principles of Mathematica / Strings and Characters  /

2.7.5 Special Characters

In addition to the ordinary characters that appear on a standard keyboard, you can include in Mathematica strings any of the special characters that are supported by Mathematica.

  • Here is a string containing special characters.
  • In[1]:= "..."


  • You can manipulate this string just as you would any other.
  • In[2]:= StringReplace[%, "" -> " "]


  • Here is the list of the characters in the string.
  • In[3]:= Characters[%]


    In a Mathematica notebook, a special character such as can always be displayed directly. But if you use a text-based interface, then typically the only characters that can readily be displayed are the ones that appear on your keyboard.
    As a result, what Mathematica does in such situations is to try to approximate special characters by similar-looking sequences of ordinary characters. And when this is not practical, Mathematica

    just gives the full name of the special character.

  • In a Mathematica notebook using StandardForm, special characters can be displayed directly.
  • In[4]:= "Lamé +"


  • In OutputForm, however, the special characters are approximated when possible by sequences of ordinary ones.
  • In[5]:= % // OutputForm


    Mathematica always uses full names for special characters in InputForm. This means that when special characters are written out to files or external programs, they are by default represented purely as sequences of ordinary characters.
    This uniform representation is crucial in allowing special characters in Mathematica to be used in a way that does not depend on the details of particular computer systems.

  • In InputForm the full names of all special characters are always written out explicitly.
  • In[6]:= "Lamé +" // InputForm


    Ways to enter characters in a string.

  • You have to use \ to "escape" any " or \ characters in strings that you enter.
  • In[7]:= "Strings can contain \"quotes\" and \\ characters."


  • \\ produces a literal \ rather than forming part of the specification of

  • In[8]:= "\\[Alpha] is \[Alpha]."

    Out[8]= is


  • This breaks the string into a list of individual characters.
  • In[9]:= Characters[%]

    Out[9]= {\, [, A, l, p, h, a, ], , i, s, ,

    , .}

  • This creates a list of the characters in the full name of


  • In[10]:= Characters[ ToString[InputForm["

    "]] ]

    Out[10]= {", \, [, A, l, p, h, a, ], "}

  • And this produces a string consisting of an actual

    from its full name.
  • In[11]:= ToExpression[ "\"\\[" <> "Alpha" <> "]\""]