This is documentation for Mathematica 4, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
Wolfram Research, Inc.

Characters in StringsAdvanced Topic: Newlines and Tabs in Strings

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]:= "AlphaCirclePlusBetaCirclePlus..."

Out[1]=

You can manipulate this string just as you would any other.

In[2]:= StringReplace[%, "CirclePlus" -> " CircleDotCircleDot "]

Out[2]=

Here is the list of the characters in the string.

In[3]:= Characters[%]

Out[3]=

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é LongRightArrowAlphaBeta+"

Out[4]=

In OutputForm, however, the special characters are approximated when possible by sequences of ordinary ones.

In[5]:= % // OutputForm

Out[5]//OutputForm= "Lamé LongRightArrowAlphaBeta+"

Out[5]//OutputForm= "Lamé LongRightArrowAlphaBeta+"

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é LongRightArrowAlphaBeta+" // InputForm

Out[6]//InputForm= "Lamé LongRightArrowAlphaBeta+"

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

Out[7]=

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

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

Out[8]=

This breaks the string into a list of individual characters.

In[9]:= Characters[%]

Out[9]=

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

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

Out[10]=

And this produces a string consisting of an actual from its full name.

In[11]:= ToExpression[ "\"\\[" <> "Alpha" <> "]\""]

Out[11]=

Characters in StringsAdvanced Topic: Newlines and Tabs in Strings