Use Character Codes to Extract Special Characters from Text

Sometimes when you import text, it will contain special characters that you want to get rid of. The functions ToCharacterCode and FromCharacterCode can be used to get special characters out of a block of text.

This string of text, from the Declaration of Independence, contains a variety of special characters. Since the character codes for these special characters are much larger than those of the other characters in the text, you can use Select to extract them and then use FromCharacterCode to reconstruct them from their raw character codes:
Click for copyable input
Click for copyable input
Click for copyable input
New to Mathematica? Find your learning path »
Have a question? Ask support »