Infinite Loop / The Apple Ecosystem

Unleash the power of Unicode on your Mac

Use the Character Palette, the Keyboard Viewer, and TextEdit to find, type, …

In English, letters with accents (diacritics) are pretty rare. Since Midæval times, diacritics have apparently fallen into disfavor. These days, people would rather cooperate than coöperate and are no longer in the habit of reading Brontë in a café while enjoying their latte. But in most other European languages, accented letters are still very much in use, and then there are the languages that use non-Latin scripts, such as Arabic, Chinese, Greek, Hebrew, and Russian. In the 1980s, every country or language had one or more different character sets or "code pages" that made it possible to write in that language on a computer. However, this meant that Greek letters could magically be transformed into Cyrillic ones when moving a file to a different computer, and using several different scripts in one document was extremely hard, if possible at all.

Fortunately, these days we have Unicode, which can encode pretty much every character in every script used by any language, dead or alive. So today, accents and non-Latin scripts simply work... most of the time, at least. The Mac has a series of tools that make it easier to work with Unicode. The first one can be found under the "Edit" menu as "Special characters." This menu item opens the character palette, which allows you to browse through the Unicode table in a variety of ways. Every character even has a name, which is searchable, and you can add characters to a list of favorites for easy access. Clicking on "Insert" inserts the currently-selected character in the active application, just like you typed it.

You can actually type a good number of characters on the keyboard. For instance, the ë in Brontë is created by first typing Alt-U (or Option-U, if you prefer) and then E. If you type some other letter in place of the E, you'll get the umlaut on that letter, if the combination makes sense. Similar working "dead keys" are available with Alt-E for é, Alt-I for ô, Alt-` for ù and Alt-n for ñ. If you go to "International" in the System Preferences, there is an option Input Menu. This lets you select "Input methods" that are appropriate for different languages. Even if you want to stick to just standard US, you may want to select the Keyboard Viewer and enable "Show input menu in the menu bar." Not only will this give you a nice, patriotic flag in your menu bar, but clicking on the flag will give you the option of bringing up the Keyboard Viewer, which does mostly what its name implies: it shows you a representation of a keyboard, showing you what letter is attached to what key. This is extremely helpful when you use a non-standard keyboard layout, or if you want to discover what letters hide under the alt and shift keys.

Should you ever run into improperly-displayed text in Safari or Mail, then you can override the standard text encoding using the View > Text Encoding menu in Safari or the the Message > Text Encoding menu in Mail. Just go through the options until the text makes sense. You can use this mechanism in Safari if you have a text file in a strange encoding: open the text file in Safari, select the appropriate encoding, copy the text from the Safari window into another application, such as TextEdit, and save the text as Unicode UTF-8.

TextEdit will also save your life when you have a text file that's in Unicode, but not in UTF-8. The original Unicode specification allowed for some 65,000 characters, and the current one for more than a million. A byte in memory, on the other hand, can only hold numbers between 0 and 255. With two bytes, it's possible to encode a little over 65,000 characters, and four bytes will give you everything Unicode has to offer and then some. So Unicode text can show up in a format called UTF-16 or UCS-2, which uses two bytes (16 bits) for almost all characters, or as UTF-32 or UCS-4, which uses four bytes (32 bits). However, the most common Unicode format on the Mac, Unix, Linux, and the web is UTF-8. UTF-8 uses a variable number of bytes per character. Plain Latin unaccented letters use one byte per character, accented letters, non-Latin scripts and other more esoteric characters use two or three or even more bytes. Programs that were made to work with simple ASCII text can work with UTF-8 without too many problems, hence its popularity. Should you ever encounter a text file in UTF-16 or UTF-32, open the file in TextEdit with the appropriate encoding, and save it back out again in UTF-8 so you can work on the file with other applications that only understand Unicode in UTF-8, which is most of them. For an example of what Unicode can do, see the UTF-8 sampler.

Expand full story

You must to comment.