CSC151 2007S, Class 36: Characters and Strings Admin: * EC: Talk Thursday on video editing with Scheme at 4:30 3821 * Questions on the exam? * Sam does respond to email intermittently * Reading for Thursday: Files Overview: * Review: Primitive Types * Representing text. * Characters: The basic building blocks. * Combining characters into strings. =Theme of Course: To Write Algorithms, We Need Basic Building Blocks= * Types: Kinds of values we can compute with * Procedures: Operations on those types * Examples * Numbers * Colors * Strings (today's lesson, plus the simple strings we've learned in the past) * Lists * Booleans * Spots (User defined, rather than primitive) * Ums * Images * Procedures (built with lambda) =Today: Another Common Pair of Types= * Much of modern computing requires text processing * Three basic types * Strings: Collections of letters (and other things you can type) * Characters: The things that make up strings * Files: How we store strings for reuse later In writing algorithms that use a type, we need to know * The general group of values that are included in the type * How to represent the basic values in the type * How do I say "the letter a" or "the string a" * Different languages make different decisions * What operations can be used on values in the type Scheme: Basic Character Issues * Use national/international standards to say what a character is * Traditionally: ASCII * Defines 128 characters * What you can traditionally type on a US Keyboard * Some hidden control characters useful for computers * These days: Unicode * Characters used in every natural language * Including Klingon * ASCII is a subset of Unicode How to represent characters: * Mostly #\ followed by the character "The letter a" #\a "The chracter 1" #\1 * Sometimes #\ followed by a name #\space Scheme: Strings are collections of characters * Surround by quotation marks, don't worry about #\ =Notes from the Lab= * Even those (integer->char 1) gives #\x, that is not "the letter x". Rather, it's some character that can't be represeneted, and our implementation of Scheme represents all such characters as #\x. 000 0 00 NUL ’\0’ 100 64 40 @ 001 1 01 SOH (start of heading) 101 65 41 A 002 2 02 STX (start of text) 102 66 42 B 003 3 03 ETX (end of text) 103 67 43 C 004 4 04 EOT (end of transmission) 104 68 44 D 005 5 05 ENQ (enquiry) 105 69 45 E 006 6 06 ACK (acknowledge) 106 70 46 F 007 7 07 BEL ’\a’ (bell) 107 71 47 G