CIS 234: Character Codes Dr. Ralph D. Westfall April, 2011.

Slides:



Advertisements
Similar presentations
L2:CSC © Dr. Basheer M. Nasef Lecture #2 By Dr. Basheer M. Nasef.
Advertisements

ICS312 Set 2 Representation of Numbers and Characters.
CIS 234: Using Data in Java Thanks to Dr. Ralph D. Westfall.
Introduction to Computers and Programming Lecture 7:
1 Lab Session-IV CSIT-120 Spring 2001 Lab 3 Revision and Exercises Rev: Precedence Rules Lab Exercise 4-A Machine Language Programming The “Micro” Machine.
Working with the data type: char  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming.
Characters and Strings. Characters In Java, a char is a primitive type that can hold one single character A character can be: –A letter or digit –A punctuation.
1 Chapter 2: Elementary Programming Shahriar Hossain.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
Data Representation (in computer system) Computer Fundamental CIM2460 Bavy LI.
IT-101 Section 001 Lecture #4 Introduction to Information Technology.
© BYU 02 NUMBERS Page 1 ECEn 224 Binary Number Systems and Codes.
Representing Information in Binary (Continued)
CHARACTERS Data Representation. Using binary to represent characters Computers can only process binary numbers (1’s and 0’s) so a system was developed.
Working with Files CSC 161: The Art of Programming Prof. Henry Kautz 11/9/2009.
CIS 234: Strings (click, scroll down)Strings Dr. Ralph D. Westfall April, 2010.
Binary Numbers and ASCII and EDCDIC Mrs. Cueni. Data Representation  Human speech is analog because it uses continuous signals (waves) that vary in strength.
Agenda Data Representation – Characters Encoding Schemes ASCII
The character data type char
Computers Organization & Assembly Language
C Programming Lecture 3. The Three Stages of Compiling a Program b The preprocessor is invoked The source code is modified b The compiler itself is invoked.
1 Lab Session-III CSIT-120 Fall 2000 Revising Previous session Data input and output While loop Exercise Limits and Bounds Session III-B (starts on slide.
1 Introduction Chapter 1 n What is Assembly Language? n Data Representation.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
ICS312 Set 1 Representation of Numbers and Characters.
Characters The data type char represents a single character in Java. –Character values are written as a symbol: ‘a’, ‘)’, ‘%’, ‘A’, etc. –A char value.
CIS 234: Numbering Systems Dr. Ralph D. Westfall April, 2010.
Globalisation & Computer systems Week 5/6 Character representation ACII and code pages UNICODE.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Data Files on Computers Text Files (ASCII) Files that can be created by typing on the keyboard while using a text editor such as notepad or TextEdit.
Computer Science Binary. Binary Code Remember the power supply that is inside your computer and how it sends electricity to all of the components? That.
Representing Characters in a computer Pressing a key on the computer a code is generated that the computer can convert into a symbol for displaying or.
Data Representation, Number Systems and Base Conversions
The character data type char. Character type char is used to represent alpha-numerical information (characters) inside the computer uses 2 bytes of memory.
Springfield Technical Community College Center for Business and Technology.
Character Encoding & Handling doubles Pepper. Character encoding schemes EBCDIC – older with jumps in alphabet ASCII 1967 (7 bit)– Handled English, –ASCII.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
M204 - Data Representation
© 2001, Penn State University Encoding on the Internet Elizabeth J. Pyatt CETS.
Representing Characters in a Computer System Representation of Data in Computer Systems.
17-Mar-16 Characters and Strings. 2 Characters In Java, a char is a primitive type that can hold one single character A character can be: A letter or.
A+ Computer Repair Lesson 3: Number System. Objectives Define binary, decimal, octal, and hexadecimal numbering systems. Define binary, decimal, octal,
THE CODING SYSTEM FOR REPRESENTING DATA IN COMPUTER.
1.4 Representation of data in computer systems Character.
Data Representation COE 308 Computer Architecture
Binary Representation in Text
Binary Representation in Text
Chapter 8 & 11: Representing Information Digitally
Machine level representation of data Character representation
Chapter 3 Data Representation Text Characters
Data Representation ICS 233
Lec 3: Data Representation
Chapter 2 Basic Computation
Data Representation.
BINARY CODE.
ECE Application Programming
EPSII 59:006 Spring 2004.
Data Representation ASCII.
Coding Schemes and Number Systems
Representing Characters
Data Representation COE 301 Computer Organization
Literal data.
Information Representation
Data Representation ICS 233
Abstraction – Number Systems and Data Representation
Literal data.
Lecture 36 – Unit 6 – Under the Hood Binary Encoding – Part 2
ASCII and Unicode.
Data Representation COE 308 Computer Architecture
Presentation transcript:

CIS 234: Character Codes Dr. Ralph D. Westfall April, 2011

Problem 1 (other PowerPoint)PowerPoint computers only understand binary coded data (zeros and ones) , , people like to count in decimals =0, =255, =85 1 st problem: it is extremely hard for people to work with binary data

Problems 2a and 2b since computers only work with numbers, they need to use numbers to identify letters to print or show on screen e.g., =65=A people who don't read English also use computers next problem: what kind of numbering should be used for different languages?

Problem 2 Solution using binary data to display characters make up a "coding scheme" that assigns characters to numbers ASCII code: 7-8 bits (1 byte) Unicode: 16 bits (2 bytes)

ASCIIASCII Code used for teletypes before computers 128 characters in original ASCII 0 to 31 (decimal) control the machine 7 (BEL) rings bell 8 (BS) backspace key 10 (LF) line feed (go down 1 line) 13 (CR) carriage return (to left of page) Java: '\n' = 10 and 13 together (2 bytes)

ASCII Characters A = 41 hex (65 decimal), Z = 5A h (90) a = 61 hex (97 decimal), z = 7A h (122) see calculator (String or ASCII choices)calculator space character = 20 hex (32 decimal) see how space character code is used in browser Address textbox see ; (semicolon) = 3B hex (59 decimal)

Printable ASCII Characters (space) ASCII mage is from WikipediaWikipedia

ASCII Numbers codes are for characters on screen and do NOT equal the values of the characters Code numeric values can NOT be used in calculations without adjustments 0 = 30 hex (ASCII 0 is really 48 decimal) 9 = 39 hex (57 decimal)

Unicode ASCII is a 7-8 bit encoding scheme character limit Unicode is a 16-bit scheme Uni comes from the word universal (also from Unix) can code 65,536 characters (actually more)actually more Java uses Unicode encoding so that it can be used for many different languages

Unicode - 2 Unicode characters for many languages Unicode Western alphabets: Latin (English), Greek, Cyrillic (Russian), etc. Unicode uses ASCII for English = A (65 decimal) Asian characters: CJK (Chinese, Japanese, Korean) has over 20,000 charactersCJK many character systems require installing special fonts onto user's computer

Using Unicode in Java char letter = 'A' ; //easiest way char letter = '\u0041' ; // also = 'A' char letter = '\u3220' ; // or '\u3280' ; // 1 Chinese character for 1Chinese \ (backslash) = escape character \u means Unicode (#s are in hexadecimal) char sound = '\u0007' ; // BEL sounds speakers when "printed" to screen

Review Questions How many bits are there in ASCII code? How many bits are there in Unicode? True or False: All ASCII codes can be seen as characters on the screen How many characters can be printed using ASCII? Using Unicode? (match 2) around 90, around 12,000, over 50,000

Review Questions - 2 Why was Unicode created to handle over 50,000 characters? Give an example of what some non- printable ASCII character does on a computer or screen How does Java code need to handle calculations on numeric characters entered on the screen by the user

Review Questions - 3 Is a space a character? What is the Chinese character for the number 1? 2? 3? this will NOT be on a test! see answers on next slide

Chinese Characters: 3, 2 and 1

Appendix the following slides show how ASCII characters can be read from the keyboard and converted to values that can be used for mathematical calculations

Reading Characters in DOS int iInit = System.in.read() ; gets numeric value of character it reads if character is A, iInit = 65 (decimal) char cInit = (char) System.in.read() ; (char) "casts" (converts) numeric value to character type System.out.println(iInit) ; //number System.out.println(cInit) ; //character

Reading Characters in Java characters sent when hit Enter key CR (13) and then LF (10 decimal) when accepting keyboard input from DOS window in Java, need to "absorb" both characters from Enter keystroke System.in.read(); reads characters, doesn't store (=) them program is now ready to read next input

Using Characters for Math numbers (characters) read from keyboard have numeric values need to convert character's decimal value to its mathematical value 0 = 30 h (48 decimal), 9 = 39 h (57) math value = decimal value – 48 int quantity = System.in.read() – 48 ; codecode // notes