Download presentation
Presentation is loading. Please wait.
1
AP CSP: Encoding and Sending Formatted Text
September 7, 2016
2
Introduction: Last class we used binary data(bits) to send information to our partners indicating coordinates on a grid. We basically encoded numbers using binary. Today we are going to take it a step further and look how we can encode text with a binary representation. If we know how to encode text in binary then we can encode all types of information. We send text data through the internet all the time, which means text is represented as bits. If it were up to you, how would you encode text in binary? Write down your ideas in your journal? You don’t need to specify every detail of the scheme, you just need to outline the structure
3
Questions to Consider:
How many bits does your encoding scheme require? For example, how many bits would you need to say “hello”? Did you account for anything besides the letters of alphabet (or whole words)?
4
ASCll Encoding Scheme:
You just invented your own scheme for encoding text with numbers. There is also an extremely popular encoding scheme that is common place today. That encoding is called the American Standard Code for Information Interchange or ASCII (pronounced: “Ask-ee”). ASCll uses 8 bits to represent the various characters that we use to represent different types of information. ASCII codes were originally 7 bits long and so there are 128 possible values. 0-31 are “control characters” that are largely defunct and go unused; they were formerly used to control various aspects of machines and printers. 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.
5
ASCll Pre-Activity: Using the ASCll table, translate your first name from letters to numbers. Write your name as: “Name!” (capital first letter, exclamation point at the end) 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.
6
Creating your own Text Formatting Protocol:
Sometimes we need to represent more then just characters when communicating information. Sometimes we need other things like: Today you will develop a protocol for sending formatted text using the internet simulator.
7
Guidelines and Rules: Both the text and formatting instructions must be derived from the printable ASCll character set(i.e. codes ). Your protocol must encode at least: bold, italics, and underlining three different font sizes (large, medium, and small) three different font colors (red, black, blue) You will demonstrate that your protocol works by sending a message with the Internet Simulator You will send a message and the recipient must be able to faithfully draw (or produce in some fashion) the formatted text, based only on the data she received. Here’s a sample message: Iteratively test your protocols to make sure you have not overlooked any gaps in your protocol.
8
Wrap-up Today all of you created a text-based code for sending formatted text. In a sense you created a coding language. HTML, Java, C++, Python, etc. all use ASCll text to encode other text or information. This is exactly the same thing you did when creating your protocol. Even though your protocol is something no one else will use, the process you went through gives a taste of inventing any kind of formal language or protocol that ultimately needs to be interpreted and processed by a computer. Most web browsers allow you to view the source code for a website. Looking at HTML we can see how they represent different texts formats and compare it with your system. If you’re interested in looking at some more HTML, go to the website below
9
Closing Question: Take a moment to think about the layers of encodings that allowed for formatted text to be transmitted over the Internet. Imagine someone pointed to piece of formatted text and asked: ‘Can you explain to me how this is encoded in binary?’ How would you explain it?”
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.