What is a charlist in Elixir

Published on

2 min read

A charlist in Elixir is

a list of Unicode code points

For example, if you use your IEx shell (using the iex command) and type:

iex(24)> i [104, 101, 108, 108, 111]

you’ll get the following output:

iex(24)> i [104, 101, 108, 108, 111]
Term
'hello'
Data type
List
Description
This is a list of integers that is printed as a sequence of characters
delimited by single quotes because all the integers in it represent printable
ASCII characters. Conventionally, a list of Unicode code points is known as a
charlist and a list of ASCII characters is a subset of it.
Raw representation
[104, 101, 108, 108, 111]
Reference modules
List
Implemented protocols
Collectable, Enumerable, IEx.Info, Inspect, List.Chars, String.Chars

The list [104, 101, 108, 108, 111] is a list of printable ASCII numbers, thus when evaluated is treated as a charlist