Back to Hugo

rune

docs/content/en/quick-reference/glossary/rune.md

0.161.1817 B
Original Source

A rune is a way to represent a single character as a number. In Hugo and Go, text is stored as a sequence of bytes. However, while a basic letter like x uses only one byte, a single character such as the German ü is made up of multiple bytes. A rune represents the entire character as one single value, no matter how many bytes it takes to store it.

Technically, a rune is just another name for a 32-bit integer. It stores the Unicode code point, which is the official number assigned to that specific character.

When you want to manipulate text character-by-character rather than by raw data size, you are working with runes. You write a rune in a template using a rune literal, such as 'x', '\n', or 'ü'.