Lesson 1-10 AP Computer Science Principles Encoding Text Lesson 1-10 AP Computer Science Principles
Objectives Students will be able to: Create a protocol for sending messages of text and use it to send messages with the Internet Simulator. Explain the need for a ‘unified’ protocol for text- based communication between machines Explore abstractions that allow them to focus on new higher-level problems
Journal One of the most powerful uses of the internet is sending text to people. Since the internet can only send bits around we need a way to encode text with bits… If it were up to you, how would you encode text in binary? Quickly, jot down an idea for encoding text.
ASCII You just invented your own scheme for encoding text with numbers. There is a standard encoding for most of the symbols you can type on an American keyboard. That encoding is called the American Standard Code for Information Interchange or ASCII (“Ask-ee”).
ASCII Facts ASCII codes were originally 7 bits long and so there are 128 possible values 0-31 are “control characters” that largely defunct and go unused, they used to be used to control various aspects of machines and printers. 32-126 are printable characters and include the numbers 0-9, all 26 letters both lowercase and uppercase, and many common punctuation symbols. 127 is the symbol for delete Over time 8-bits became a standard “chunk-size” for encoding information. ASCII made the transition to this 8-bit encoding by just adding an extra 0 to the front of the old 7-bit codes.
Journal In your journals write your full name in ASCII Mr. Schmidt = 1001101 1110010 0101110 0100000 1010011 1100011 1101000 1101101 1101001 1100100 1110100
ASCII Mr. Schmidt = 77 114 46 32 83 99 104 109 105 100 116
What about Formatted Text? Having a standardized protocol like ASCII to encode text enables us to send and receive textual information. This is very useful, but there are still instances when we will want even greater expressive power in our digital communications.
What about Formatted Text? “What if you wanted to send formatted text that included things like the ability to underline, bold, or italicize words....specify a different font size, or color?” Things like:
Sending Formatted Text Download the activity guide for today Develop a protocol for encoding formatting information alongside regular text. Both the text and the formatting instructions must be derived from the printable ASCII character set (i.e. codes 32-126). You protocol must encode at least: bold, italics, and underlining three different font sizes (large, medium, and small) three different font colors (red, black, blue)
Develop Your Protocol Write it down! All members of your team must be able to use the protocol. I will split your group up and give you a message to send. The other person must correctly decode the message.
Stage 7 Complete Stage 7