Mapping Single Characters to Other Values

Testing a character for membership in a class is really just a special case of mapping from a single character to a single value—in essence, you're mapping from a character (or, more accurately, a code unit) to a Boolean value. Most of the time, however, you want to map to something with more possible values than a Boolean value. For example, instead of checking whether a character is a member of some class, you may want to perform one operation to see which of several mutually exclusive classes a given character belongs to (as opposed to checking each category one by one for the character, as you might have to do if the categories overlapped). There are plenty of other uses for this kind of thing: mapping ...

Get Unicode Demystified now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.