ToCharacterCode

ToCharacterCode["string"]
gives a list of the integer codes corresponding to the characters in a string.

ToCharacterCode["string","encoding"]
gives integer codes according to the specified encoding.

DetailsDetails

  • ToCharacterCode handles both ordinary and special characters.
  • ToCharacterCode["string"] returns standard internal character codes used by the Wolfram Language, which are the same on all computer systems.
  • For characters on an ordinary American English keyboard, the character codes follow the ASCII standard.
  • For common European languages, they follow the ISO Latin1 standard.
  • For other characters, they follow the Unicode standard.
  • The Wolfram System defines various additional characters in private Unicode space, with character codes between 64256 and 64300.
  • Character codes returned by ToCharacterCode["string"] lie between 0 and 65535.
  • Encodings supported in ToCharacterCode["string","encoding"] are listed in the notes for $CharacterEncoding.
  • If a particular character has no character code in a given encoding, ToCharacterCode returns None in place of a character code.
  • ToCharacterCode[{"s1","s2",}] gives a list of the lists of integer codes for each of the .

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

Find ASCII or Unicode character codes:

In[1]:=
Click for copyable input
Out[1]=

Reassemble a string from character codes:

In[2]:=
Click for copyable input
Out[2]=
Introduced in 1991
(2.0)
| Updated in 1999
(4.0)