CSC151 2007S, Class 32: Characters and Strings * Welcome back! I hope you had a relaxing break. * I will continue to reserve time at the start of class for discussion of campus issues. Admin: * I have finished grading exam 2. I will distribute an answer key after class. * Are there questions on Assignment 7? * Reading for tomorrow: Files. Overview: * Representing text. * Characters: The basic building blocks. * Combining characters into strings. ==Computing with Text== * We've done * Algorithms with numbers * Algorithms with colors * Algorithms with images * But we should also be able to write algorithms that deal with text * We need (at least) three things * An internal representation of text (a "type") * Basic procedures for working with that type (or those types) * Our standard Scheme techniques: Conditionals, sequencing, names, letrec, ...q * Goal today: Learn types and basic procedures * Two basic types: * Strings (e.g., text) * Chararacters, building blocks of strings ==Characters== * Represent character constants with obscene notation. To talk about the letter a, we can't write a (looks like a name to Scheme), can't write 'a (a symbol), can't write "a" (a string), so we write #\a * One character strings are represented differently than single characters * Perhaps because we compute with them differently. * In the internal representation of characters, there is a sequence of characters We call it the "collating sequence" Because we have this sequence, the computer can think of each char as a number * You can see a list of ASCII characters by opening a terminal window and typing man ascii ==Strings== * 0-based sequences of characters * Constants represent with double-quotation-marks "triskaidekaphobia"