Lesson 9. Multilingual text
After reading lesson 9, you’ll be able to
- Access and manipulate individual letters
- Cipher and decipher secret messages
- Write your programs for a multilingual world
From "Hello, playground" at the beginning, you’ve been using text in your programs. The individual letters, digits, and symbols are called characters. When you string together characters and place them between quotes, it’s called a literal string.
Consider this
You know computers represent numbers with 1s and 0s. If you were a computer, how would you represent the alphabet and human language?
If you said with numbers, you’re right. Characters of the alphabet have numeric values, which means you can manipulate them like numbers.
It’s not entirely straightforward, though. The characters from every written language and countless emoji add up to thousands of characters. There are some tricks to representing text in a space-efficient and flexible manner.
Literal values wrapped in quotes are inferred to be of the type string, so the following three lines are equivalent:
If you declare a variable without providing a value, it will be initialized with the zero value for its type. The zero value for the string type is an empty string (""):