Text Code

Share

What is a Text Code?

A text code is a code that encodes data as text, in the text format, as opposed to a binary format or numeric format (although some text codes are made entirely out of numbers). Text codes are used in computers because humans can read them and can write them, even by hand. As you use a computer, there are many times you can tell the computer to do something by typing a text, or by copying and pasting a text. In these cases, sometimes this text is a text code. This means there is a computer program responsible for decoding the text code into something more meaningful for the computer.

See How Computers Parses Text Codes for a detailed explanation.

Examples

Some example of text codes are:

  • Domain names, e.g. www.example.com.
  • URLs, e.g. https://www.example.com/webpage?q=query#fragment.
  • Filepaths, e.g. C:\folder\photo.jpg, /home/me/Pictures/photo.jpg, ~/Pictures/photo.jpg.
  • Search operators, e.g. site:reddit.com "the illusionist" -memes.
  • E-mail addresses, e.g. [email protected].
  • HTML code, e.g. <a href="#">link</a>.
  • BB code, e.g. :[url=www.example.com]link[/url].
  • Markdown code, e.g. *italic*, **bold**.
  • Other social media text formatting code, e.g. :emoji:, @mention, #hashtag.
  • Color hex codes, e.g. #ff0000, #F00.
  • Non-decimal number codes, e.g. 0b1010, 0xff.
  • Bytes as hexadecimals, e.g. f0 2b da 31.
  • Byte-addressable memory addresses, e.g. BAADF00D, BADC0FFEE0DDF00D.
  • Glob patterns, e.g. *.jpg|*.jpeg|*.png|*.gif.
  • Regex patterns: ^.*\.(jpe?g|gif|png)$.

Notable Features

Different types of text codes have different purposes, but there are some common features we can observe across them.

Some text codes are used to identify things, such as URLs, filepaths, and e-mail addresses. In some cases, this code can be case-sensitive, in other cases it's not. For example, domain names are case-insensitive. This means WWW.EXAMPLE.COM and www.example.com are the same thing. On Windows, filepaths are case-insensitive, too. This means you can't have two files with the same name but spelled with different case. However, on Linux, filepaths are case-sensitive, which means you can have a photo.jpg and a PHOTO.JPG in the same directory.

When it's possible to include arbitrary text inside a text code, that text code tends to feature special characters, also known as reserved characters, that can't be directly included in the arbitrary text, and a way to include them called escaping. For example, in Markdown, * is a special character that formats text as italic or bold. To type * without triggering such formatting, you would type \*. In doing this, we say the asterisk has been "escaped." Similarly, in regex, . is a special character that means "any character," so to use . in regex, it needs to be escaped as \.. In URLs, characters are "percent-escaped" instead. For example, URLs can't have spaces in them, so spaces are reserved characters. To type a space in a URL, you would type %20.

A text code can be entirely made out of numbers. Anything you type in the computer is text, that is, is data in text format, including any numbers you type. For the computer to do math, it needs the data to be in a numeric format. Consequently, every time you type a number that will be added, subtracted, multiplied, etc., there is a computer program that needs to run to convert the text you typed into numbers that the CPU can use in its calculations. As far as the CPU is concerned, the numbers you type are text code until they are converted.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *