Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • DSA
  • Practice Problems
  • Python
  • C
  • C++
  • Java
  • Courses
  • Machine Learning
  • DevOps
  • Web Development
  • System Design
  • Aptitude
  • Projects
Open In App
Next Article:
ASCII Values Alphabets ( A-Z, a-z & Special Character Table )
Next article icon

What is ASCII - A Complete Guide to Generating ASCII Code

Last Updated : 04 Dec, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

The American Standard Code for Information Interchange, or ASCII, is a character encoding standard that has been a foundational element in computing for decades. It plays a crucial role in representing text and control characters in digital form.

ASCII-American-Standard-Code-for-Information-Interchange-1

Historical Background

ASCII has a rich history, dating back to its development in the early 1960s. Originating from telegraph code and Morse code, ASCII emerged as a standardized way to represent characters in computers, facilitating data interchange.

Importance in Computing

ASCII's significance in computing lies in its universality. It provides a standardized method for encoding characters, allowing seamless communication and data exchange across diverse computing systems.

Table of Content

  • ASCII Encoding Standards
  • ASCII Representation
  • ASCII in Computing
  • ASCII Extended Sets
  • ASCII vs. Unicode
  • Practical Examples of ASCII
  • Limitations of ASCII
  • Handling Non-ASCII Characters

ASCII Encoding Standards

ASCII Character Set

The ASCII character set includes standard characters such as letters, numbers, punctuation, and control characters. Each character is assigned a unique seven-bit binary code.

DecimalCharacterDescription
0NULNull
1SOHStart of Header
2STXStart of Text
3ETXEnd of Text
4EOTEnd of Transmit
5ENQEnquiry
6ACKAcknowledge
7BELBell
8BSBackspace
9HTHorizontal Tab
10LFLine Feed
11VTVertical Tab
12FFForm Feed
13CRCarriage Return
14SOShift Out
15SIShift In
.........
32(space)Space
33!Exclamation Mark
34"Quotation Mark
.........
65AUppercase A
66BUppercase B
.........
97aLowercase a
98bLowercase b
.........
127DELDelete

ASCII Control Characters

In addition to printable characters, ASCII includes control characters for formatting and controlling devices. These include characters like carriage return and line feed.

DecimalCharacterDescription
0NULNull
1SOHStart of Header
2STXStart of Text
3ETXEnd of Text
4EOTEnd of Transmit
5ENQEnquiry
6ACKAcknowledge
7BELBell
8BSBackspace
9HTHorizontal Tab
10LFLine Feed
11VTVertical Tab
12FFForm Feed
13CRCarriage Return
14SOShift Out
15SIShift In

ASCII Extended Characters

While the original ASCII set comprises 128 characters, extended ASCII introduces an additional 128 characters, accommodating symbols and characters for different languages.

DecimalCharacterDescription
128ÇLatin Capital Letter C-cedilla
129üLatin Small Letter U with Diaeresis
130éLatin Small Letter E with Acute
131âLatin Small Letter A with Circumflex
132äLatin Small Letter A with Diaeresis
133àLatin Small Letter A with Grave
134åLatin Small Letter A with Ring Above
.........
255ÿLatin Small Letter Y with Diaeresis

ASCII Table

A comprehensive ASCII table organizes characters and their corresponding binary, decimal, and hexadecimal representations.

DecimalHexBinaryCharacterDescription
00000000000NULNull
10100000001SOHStart of Header
20200000010STXStart of Text
30300000011ETXEnd of Text
40400000100EOTEnd of Transmit
50500000101ENQEnquiry
60600000110ACKAcknowledge
70700000111BELBell
80800001000BSBackspace
90900001001HTHorizontal Tab
100A00001010LFLine Feed
110B00001011VTVertical Tab
120C00001100FFForm Feed
130D00001101CRCarriage Return
140E00001110SOShift Out
150F00001111SIShift In
161000010000DLEData Link Escape
171100010001DC1Device Control 1 (oft. XON)
181200010010DC2Device Control 2
191300010011DC3Device Control 3 (oft. XOFF)
201400010100DC4Device Control 4
211500010101NAKNegative Acknowledge
221600010110SYNSynchronous Idle
231700010111ETBEnd of Transmission Block
241800011000CANCancel
251900011001EMEnd of Medium
261A00011010SUBSubstitute
271B00011011ESCEscape
281C00011100FSFile Separator
291D00011101GSGroup Separator
301E00011110RSRecord Separator
311F00011111USUnit Separator
322000100000(space)Space
332100100001!Exclamation Mark
342200100010"Quotation Mark
352300100011#Number Sign
362400100100$Dollar Sign
372500100101%Percent Sign
382600100110&Ampersand
392700100111'Apostrophe (Single Quote)
402800101000(Left Parenthesis
412900101001)Right Parenthesis
422A00101010*Asterisk
432B00101011+Plus Sign
442C00101100,Comma
452D00101101-Hyphen (Minus Sign)
462E00101110.Period (Full Stop)
472F00101111/Solidus (Slash)
4830001100000Digit Zero
4931001100011Digit One
5032001100102Digit Two
5133001100113Digit Three
5234001101004Digit Four
5335001101015Digit Five
5436001101106Digit Six
5537001101117Digit Seven
5638001110008Digit Eight
5739001110019Digit Nine
583A00111010:Colon
593B00111011;Semicolon
603C00111100<Less Than (Angle Bracket, Left Pointing)
613D00111101=Equals Sign
623E00111110>Greater Than (Angle Bracket, Right Pointing)
633F00111111?Question Mark
644001000000@At Sign
654101000001AUppercase A
664201000010BUppercase B
674301000011CUppercase C
684401000100DUppercase D
694501000101EUppercase E
704601000110FUppercase F
714701000111GUppercase G
724801001000HUppercase H
734901001001IUppercase I
744A01001010JUppercase J
754B01001011KUppercase K
764C01001100LUppercase L
774D01001101MUppercase M
784E01001110NUppercase N
794F01001111OUppercase O
805001010000PUppercase P
815101010001QUppercase Q
825201010010RUppercase R
835301010011SUppercase S
845401010100TUppercase T
855501010101UUppercase U
865601010110VUppercase V
875701010111WUppercase W
885801011000XUppercase X
895901011001YUppercase Y
905A01011010ZUppercase Z
915B01011011[Left Square Bracket
925C01011100\Backslash
935D01011101]Right Square Bracket
945E01011110^Caret (Circumflex Accent)
955F01011111_Underscore
966001100000`Grave Accent
976101100001aLowercase a
986201100010bLowercase b
996301100011cLowercase c
1006401100100dLowercase d
1016501100101eLowercase e
1026601100110fLowercase f
1036701100111gLowercase g
1046801101000hLowercase h
1056901101001iLowercase i
1066A01101010jLowercase j
1076B01101011kLowercase k
1086C01101100lLowercase l
1096D01101101mLowercase m
1106E01101110nLowercase n
1116F01101111oLowercase o
1127001110000pLowercase p
1137101110001qLowercase q
1147201110010rLowercase r
1157301110011sLowercase s
1167401110100tLowercase t
1177501110101uLowercase u
1187601110110vLowercase v
1197701110111wLowercase w
1207801111000xLowercase x
1217901111001yLowercase y
1227A01111010zLowercase z
1237B01111011{Left Curly Brace
1247C01111100|Vertical Bar
1257D01111101}Right Curly Brace
1267E01111110~Tilde
1277F01111111DELDelete

ASCII Representation

Binary Representation

ASCII characters are represented in binary, providing a machine-readable format that computers use for internal processing.

BinaryCharacterDescription
00000000NULNull
00000001SOHStart of Header
00000010STXStart of Text
00000011ETXEnd of Text
00000100EOTEnd of Transmit
00000101ENQEnquiry
00000110ACKAcknowledge
00000111BELBell
00001000BSBackspace
00001001HTHorizontal Tab
00001010LFLine Feed
00001011VTVertical Tab
00001100FFForm Feed
00001101CRCarriage Return
00001110SOShift Out
00001111SIShift In
.........
00100000(space)Space
00100001!Exclamation Mark
00100010"Quotation Mark
.........
01000001AUppercase A
01000010BUppercase B
.........
01100001aLowercase a
01100010bLowercase b
.........
01111111DELDelete

Decimal Representation

In decimal form, ASCII codes offer a human-readable representation, simplifying discussions and documentation.

DecimalCharacterDescription
0NULNull
1SOHStart of Header
2STXStart of Text
3ETXEnd of Text
4EOTEnd of Transmit
5ENQEnquiry
6ACKAcknowledge
7BELBell
8BSBackspace
9HTHorizontal Tab
10LFLine Feed
11VTVertical Tab
12FFForm Feed
13CRCarriage Return
14SOShift Out
15SIShift In
.........
32(space)Space
33!Exclamation Mark
34"Quotation Mark
.........
65AUppercase A
66BUppercase B
.........
97aLowercase a
98bLowercase b
.........
127DELDelete

Hexadecimal Representation

The hexadecimal representation of ASCII codes is commonly used in programming and digital design.

HexadecimalCharacterDescription
00NULNull
01SOHStart of Header
02STXStart of Text
03ETXEnd of Text
04EOTEnd of Transmit
05ENQEnquiry
06ACKAcknowledge
07BELBell
08BSBackspace
09HTHorizontal Tab
0ALFLine Feed
0BVTVertical Tab
0CFFForm Feed
0DCRCarriage Return
0ESOShift Out
0FSIShift In
.........
20(space)Space
21!Exclamation Mark
22"Quotation Mark
.........
41AUppercase A
42BUppercase B
.........
61aLowercase a
62bLowercase b
.........
7FDELDelete

ASCII in Computing

ASCII in Programming Languages

Programming languages extensively use ASCII for representing characters and symbols in source code.

ASCII in Data Transmission

ASCII is fundamental in data transmission protocols, ensuring compatibility and readability when exchanging information between systems.

ASCII Art and Design

Artistic expressions, known as ASCII art, leverage ASCII characters to create visual designs and graphics.

ASCII Extended Sets

  • ASCII-8: ASCII-8 extends the character set, accommodating additional symbols and characters.
  • ASCII-16: In ASCII-16, further characters are added, expanding the encoding possibilities.
  • ASCII-32: ASCII-32 continues the extension, providing even more characters for diverse applications.
  • ASCII-64: With ASCII-64, the character set grows, supporting an array of symbols and international characters.
  • ASCII-128: The extended set ASCII-128 completes the 256-character spectrum, including a wide range of symbols.

ASCII vs. Unicode

Key Differences

ASCII and Unicode are both character encoding standards, but they have key differences in terms of scope and functionality. Let's compare ASCII and Unicode in a tabular format:

FeatureASCIIUnicode
DefinitionASCII (American Standard Code for Information Interchange) is a character encoding standard that uses 7 or 8 bits to represent characters, mainly limited to the English alphabet, numerals, and a few special characters.Unicode is a character encoding standard that aims to provide a unique code point for every character, regardless of platform, program, or language. It uses a variable number of bits (8, 16, or 32) to represent characters.
ScopeOriginally designed for English and a few other Western languages.Designed to be a universal character encoding standard that supports a vast range of languages, symbols, and characters from various writing systems.
Bit UsageTypically uses 7 bits (extended ASCII uses 8 bits).Can use 8, 16, or 32 bits per character, allowing it to represent a much larger number of characters.
Number of CharactersLimited to 128 (with 7 bits) or 256 (with 8 bits).Can represent over a million unique characters.
Multilingual SupportPrimarily supports English and a few Western languages.Comprehensive support for almost all languages, including scripts like Cyrillic, Arabic, Chinese, Japanese, and many others.
Backward CompatibilityLimited, as it was primarily designed for English and does not have built-in support for characters from various languages.Maintains backward compatibility with ASCII. The first 128 Unicode code points correspond to ASCII, ensuring compatibility with existing ASCII data.
RepresentationUses one byte (8 bits) per character.Variable-length encoding, using 8, 16, or 32 bits per character.
Standard OrganizationDeveloped by ANSI (American National Standards Institute).Developed by the Unicode Consortium, a non-profit organization that maintains and develops the Unicode standard.

ASCII and Unicode differ in scope, with ASCII representing 128 characters and Unicode accommodating a vast array of characters from various scripts.

When to Use ASCII vs. Unicode

While ASCII is suitable for English and basic character encoding, Unicode is preferred for multilingual and diverse character requirements.

Practical Examples of ASCII

Converting Characters to ASCII

Demonstrations on converting characters to their ASCII equivalents for practical applications.

ASCII in File Handling

ASCII, as a character encoding standard, plays a significant role in file handling. When working with text files, understanding how ASCII characters are encoded and decoded is essential. Here's how ASCII is involved in file handling:

  1. Character Representation:
    • ASCII represents characters using numeric codes. Each character is assigned a decimal value between 0 and 127, and this value is used to represent the character in binary form.
  2. Text File Encoding:
    • Text files are often encoded using ASCII or its extended forms. The encoding determines how characters are represented in the file. ASCII encoding is a common choice for plain text files, especially when dealing with English text.
  3. Binary Files:
    • While ASCII is commonly associated with text files, binary files can also use ASCII characters for metadata or textual information within the file. For example, file headers or configuration data may be encoded using ASCII.
  4. File Reading and Writing:
    • When reading from or writing to text files using programming languages, developers need to specify the character encoding. ASCII encoding (or its extensions like UTF-8) is chosen based on the nature of the data being handled.
    # Example in Python using UTF-8 encoding
    with open('example.txt', 'r', encoding='utf-8') as file:
    content = file.read()
  5. Line Endings:
    • ASCII includes control characters for line feed (LF or \n) and carriage return (CR or \r). The choice of line endings (Unix/Linux using LF, Windows using CRLF) affects how text files are handled on different operating systems.
  6. File Transfer Protocols:
    • ASCII characters are often used in file transfer protocols, especially in FTP (File Transfer Protocol). When transferring text files, the client and server may negotiate to use ASCII mode to ensure correct line ending conversions.
  7. Programming Language Support:
    • Many programming languages provide built-in functions for reading and writing files. These functions often allow developers to specify the character encoding, and ASCII encoding can be chosen when dealing with simple text files.
  8. Code Files:
    • Source code files for programming languages are often encoded using ASCII or UTF-8, which is backward-compatible with ASCII. This ensures that the code can be read and interpreted correctly by various compilers and interpreters.
  9. Metadata and Headers:
    • ASCII characters are commonly used in file metadata, headers, or configuration files where human-readable text is needed. For example, XML or JSON files may use ASCII for the textual representation of data.
  10. Error Handling:
    • When handling files, it's essential to consider error handling for cases where the file contains unexpected characters or encoding issues. Proper error handling can prevent data corruption and ensure the robustness of the application.

ASCII in URL Encoding

URL encoding, also known as percent-encoding, is a method used to represent certain characters in a URL by replacing them with a percent sign (%) followed by two hexadecimal digits. While URL encoding can encompass a broader range of characters, ASCII characters play a significant role in this process. Here's how ASCII is involved in URL encoding:

  1. Character Representation:
    • ASCII characters are a subset of the characters that can be directly used in a URL without encoding. These include alphanumeric characters (A-Z, a-z, 0-9) and a set of special characters (such as hyphen, underscore, period, and tilde).
  2. Reserved Characters:
    • Certain ASCII characters have special meanings in a URL and are reserved for specific purposes. For example:
      • Reserved Characters: ! * ' ( ) ; : @ & = + $ , / ? % # [ ] -
      • Unreserved Characters: Alphanumeric characters (A-Z, a-z, 0-9), hyphen, underscore, period, and tilde.
  3. Encoding Reserved Characters:
    • When a reserved character needs to be included in a URL, it must be URL-encoded. For instance, space is represented as %20, and the exclamation mark (!) is represented as %21. This prevents misinterpretation of these characters by the URL parser.
    Original: Hello World!
    URL Encoded: Hello%20World%21
  4. Percent Encoding:
    • Percent encoding involves representing non-alphanumeric characters using the percent sign (%) followed by two hexadecimal digits. This ensures that these characters are correctly interpreted in a URL.
    Original: /path/to/file with spaces.txt
    URL Encoded: /path/to/file%20with%20spaces.txt
  5. ASCII Control Characters:
    • ASCII control characters and non-printable characters, which are not allowed in URLs, are often excluded. However, if they need to be included, they are represented using percent encoding.
    Original: Line1\nLine2
    URL Encoded: Line1%0ALine2
  6. Programming Language Support:
    • When working with URLs in programming, libraries and functions for URL encoding are often provided. These functions take care of encoding reserved characters and ensuring that the resulting URL is valid.
    # Example in Python
    import urllib.parse

    url = "https://example.com/path with spaces"
    encoded_url = urllib.parse.quote(url)
    print(encoded_url)
  7. Query Parameters:
    • In URLs, query parameters are separated by the ampersand (&) symbol. When the parameter values contain reserved or non-alphanumeric characters, these characters are URL-encoded.
    Original: ?name=John Doe&age=30
    URL Encoded: ?name=John%20Doe&age=30

ASCII in Networking

  • ASCII in Protocols (HTTP, FTP, etc.): The integral role of ASCII in networking protocols like HTTP and FTP, ensuring standardized communication.
  • ASCII in Email Communication: ASCII's role in email systems, influencing the way messages are transmitted and displayed.
  • ASCII in Security
  • ASCII in Passwords: Exploration of ASCII's role in password representation and security considerations.
  • ASCII in Encryption: Understanding how ASCII encoding principles align with encryption algorithms for secure data transmission.

Limitations of ASCII

ASCII, while widely used and simple, has some limitations, especially in the context of modern computing needs. Here are some of the key limitations of ASCII:

  1. Limited Character Set: ASCII is limited to representing only 128 characters (7-bit encoding) or 256 characters (8-bit encoding). This limitation is restrictive when dealing with languages and writing systems beyond the basic Latin alphabet.
  2. No Support for Non-Latin Characters: ASCII does not provide support for characters outside the English alphabet, such as accented characters in European languages, characters from Asian languages, or special symbols used in various writing systems.
  3. Lack of Standardization for Extended ASCII: While ASCII itself only uses 7 bits, the extended ASCII set (8-bit encoding) is not standardized across different systems. Different extended ASCII encodings have been developed, leading to compatibility issues.
  4. No Representation for Control Characters Beyond 127: ASCII control characters with decimal values greater than 127 have specific functions (e.g., extended Latin characters), but they are not standardized. Their interpretation can vary among different systems.
  5. Not Well-Suited for Multilingual Text: As a character encoding standard, ASCII is not designed to handle the diverse needs of multilingual text representation. Modern applications often require support for a wide range of languages, which ASCII cannot accommodate adequately.
  6. Limited Symbolic Representation: ASCII lacks representation for certain symbols and mathematical characters commonly used in scientific and technical contexts. This limitation hinders its suitability for applications requiring these symbols.
  7. Fixed-Length Encoding: ASCII uses a fixed-length encoding of 7 or 8 bits per character. While this simplicity was an advantage in early computing, it is less efficient than variable-length encodings like UTF-8 used by Unicode. Variable-length encoding allows more efficient storage of characters.
  8. No Provision for Metadata or Formatting: ASCII is primarily focused on character representation and lacks provisions for metadata, formatting information, or characters with specialized functions in modern text processing.
  9. Globalization Challenges: As a result of its limitations, ASCII poses challenges when developing applications for a global audience with diverse linguistic and cultural requirements.

Handling Non-ASCII Characters

Handling non-ASCII characters is crucial when dealing with text data that goes beyond the basic Latin alphabet covered by ASCII. Here are some common approaches and considerations for handling non-ASCII characters:

  1. Unicode Encoding:
    • UTF-8, UTF-16, UTF-32: Unicode is a character encoding standard that supports a vast range of characters from different languages and writing systems. UTF-8, UTF-16, and UTF-32 are different encoding schemes under the Unicode standard, allowing representation of characters using 8, 16, or 32 bits per character, respectively.
  2. Use Unicode-Compatible Data Types:
    • When working with programming languages or databases, ensure that you use data types that support Unicode characters. For example, in many programming languages, using string or char data types that support Unicode is essential.
  3. Normalization:
    • Unicode Normalization is the process of transforming text into a standardized form, ensuring that equivalent sequences of characters are represented in a consistent way. This is important when dealing with characters that can be represented in multiple ways, such as accented characters.
  4. Libraries and Frameworks:
    • Many programming languages provide libraries and frameworks that handle Unicode and non-ASCII characters seamlessly. Utilize these libraries to ensure correct processing of text data.
  5. File Encodings:
    • When working with text files, be aware of the encoding used. UTF-8 is a common and widely supported encoding for handling Unicode characters. Make sure that the applications reading and writing files support the chosen encoding.
  6. Database Collation:
    • Database collation settings determine how string comparison operations are performed. Choose a collation that supports the language and characters you are working with. Unicode collations are designed to handle a wide range of characters.
  7. Web Page Character Encoding:
    • Specify the character encoding in the <meta> tag of HTML documents to ensure that web browsers interpret and display non-ASCII characters correctly.
  8. Regular Expressions:
    • When using regular expressions, ensure that the patterns are Unicode-aware. Many programming languages provide Unicode-aware regular expression functions.
  9. Input and Output Handling:
    • When dealing with user input or displaying information to users, ensure that input forms, databases, and web pages are configured to handle non-ASCII characters. Validate and sanitize user input to prevent issues.
  10. Testing and Internationalization:
    • Conduct thorough testing, especially if your application is intended for a global audience. Consider internationalization (i18n) best practices to make your software adaptable to various languages and regions.

By embracing Unicode and adopting best practices for handling non-ASCII characters, you can ensure that your applications are capable of supporting a wide range of languages and writing systems. This is particularly important in today's globalized and interconnected world.


Next Article
ASCII Values Alphabets ( A-Z, a-z & Special Character Table )

S

srinam
Improve
Article Tags :
  • Programming
  • ASCII

Similar Reads

  • What is ASCII - A Complete Guide to Generating ASCII Code
    The American Standard Code for Information Interchange, or ASCII, is a character encoding standard that has been a foundational element in computing for decades. It plays a crucial role in representing text and control characters in digital form. Historical BackgroundASCII has a rich history, dating
    13 min read
  • ASCII Values Alphabets ( A-Z, a-z & Special Character Table )
    ASCII (American Standard Code for Information Interchange) is a standard character encoding used in telecommunication. The ASCII pronounced 'ask-ee', is strictly a seven-bit code based on the English alphabet. ASCII codes are used to represent alphanumeric data. The code was first published as a sta
    7 min read
  • ASCII Vs UNICODE
    Overview :Unicode and ASCII are the most popular character encoding standards that are currently being used all over the world. Unicode is the universal character encoding used to process, store and facilitate the interchange of text data in any language while ASCII is used for the representation of
    3 min read
  • ASCII Value of a Character in C
    In this article, we will discuss about the ASCII values that are bit numbers used to represent the character in the C programming language. We will also discuss why the ASCII values are needed and how to find the ASCII value of a given character in a C program. Table of Content What is ASCII Value o
    4 min read
  • ascii() in Python
    Python ascii() function returns a string containing a printable representation of an object and escapes the non-ASCII characters in the string using \x, \u or \U escapes. It's a built-in function that takes one argument and returns a string that represents the object using only ASCII characters. Exa
    3 min read
  • Program to Print ASCII Conversion

    • Program to print ASCII Value of all digits of a given number
      Given an integer N, the task is to print the ASCII value of all digits of N. Examples: Input: N = 8Output: 8 (56)Explanation:ASCII value of 8 is 56 Input: N = 240Output:2 (50)4 (52)0 (48) Approach: Using the ASCII table shown below, the ASCII value of all the digits of N can be printed: DigitASCII V
      5 min read

    • Program to print ASCII Value of a character
      Given a character, we need to print its ASCII value in C/C++/Java/Python. Examples : Input : a Output : 97 Input : DOutput : 68 Here are few methods in different programming languages to print ASCII value of a given character :  Python code using ord function : ord() : It converts the given string o
      4 min read

    • Print given sentence into its equivalent ASCII form
      Given a string containing words forming a sentence (belonging to the English language). The task is to output the equivalent ASCII sentence of the input sentence. ASCII (American Standard Code for Information Interchange) form of a sentence is the conversion of each of the characters of the input st
      4 min read

    • Count and Print the alphabets having ASCII value not in the range [l, r]
      Given a string str, the task is to count the number of alphabets having ASCII values, not in the range [l, r]. Examples: Input: str = "geeksforgeeks", l = 102, r = 111Output: Count = 7Characters - e, s, r have ASCII values not in the range [102, 111]. Input: str = "GeEkS", l = 80, r = 111Output: Cou
      6 min read

    • Print each word in a sentence with their corresponding average of ASCII values
      Given a sentence, the task is to find the average of ASCII values of each word in the sentence and print it with the word. Examples: Input: sentence = "Learning a string algorithm"Output:Learning - 102a - 97string - 110algorithm - 107 Approach: Take an empty string and start traversing the sentence
      6 min read

    Program for Binary to ASCII Conversion

    • Python program to convert binary to ASCII
      In this article, we are going to see the conversion of Binary to ASCII in the Python programming language. There are multiple approaches by which this conversion can be performed that are illustrated below: Method 1: By using binascii module Binascii helps convert between binary and various ASCII-en
      3 min read

    • Program to convert given Binary to its equivalent ASCII character string
      Given a binary string str, the task is to find its equivalent ASCII (American Standard Code for Information Interchange) character string. Examples: Input: str = "0110000101100010"Output: abExplanation: Dividing str into set of 8 bits as follows: 01100001 = 97, ASCII value of 97 is 'a'.01100010 = 98
      9 min read

    Problem Related to ASCCI

    • Program to Convert ASCII to Unicode
      In this article, we will learn about different character encoding techniques which are ASCII (American Standard Code for Information Interchange) and Unicode (Universal Coded Character Set), and the conversion of ASCII to Unicode. Table of Content What is ASCII Characters?What is ASCII Table?What is
      4 min read

    • Program to Convert Unicode to ASCII
      Given a Unicode number, the task is to convert this into an ASCII (American Standard Code for Information Interchange) number. ASCII numberASCII is a character encoding standard used in communication systems and computers. It uses 7-bit encoding to encode 128 different characters 0-127. These values
      4 min read

    • Program to implement ASCII lookup table
      ASCII stands for American Standard Code for Information Interchange. Computers can only understand numbers, so an ASCII code is the numerical representation of a character such as ‘a’ or ‘@’ or an action of some sort. ASCII lookup table is a tabular representation of corresponding values associated
      7 min read

    • Program to find the product of ASCII values of characters in a string
      Given a string str. The task is to find the product of ASCII values of characters in the string. Examples: Input: str = "IS"Output: 605973 * 83 = 6059 Input: str = "GfG"Output: 514182 The idea is to start with iterating through characters of the string and multiply their ASCII values to a variable n
      4 min read

    • How to convert character to ASCII code using JavaScript ?
      The purpose of this article is to get the ASCII code of any character by using JavaScript charCodeAt() method. This method is used to return the number indicating the Unicode value of the character at the specified index. Syntax: string.charCodeAt(index); Example: Below code illustrates that they ca
      1 min read

    • Converting an Integer to ASCII Characters in Python
      In Python, working with integers and characters is a common task, and there are various methods to convert an integer to ASCII characters. ASCII (American Standard Code for Information Interchange) is a character encoding standard that represents text in computers. In this article, we will explore s
      2 min read

    • Check if a string contains uppercase, lowercase, special characters and numeric values
      Given string str of length N, the task is to check whether the given string contains uppercase alphabets, lowercase alphabets, special characters, and numeric values or not. If the string contains all of them, then print "Yes". Otherwise, print "No". Examples: Input: str = "#GeeksForGeeks123@" Outpu
      5 min read

    • How to remove all non-alphanumeric characters from a string in Java
      Given string str, the task is to remove all non-alphanumeric characters from it and print the modified it. Examples: Input: @!Geeks-for'Geeks,123 Output: GeeksforGeeks123 Explanation: at symbol(@), exclamation point(!), dash(-), apostrophes('), and commas(, ) are removed.Input: Geeks_for$ Geeks?{}[]
      3 min read

    • Convert the ASCII value sentence to its equivalent string
      Given a string str which represents the ASCII (American Standard Code for Information Interchange) Sentence, the task is to convert this string into its equivalent character sequence. Examples: Input: str = "71101101107115" Output: Geeks 71, 101, 101, 107 are 115 are the unicode values of the charac
      5 min read

    • Check whether the given character is in upper case, lower case or non alphabetic character
      Given a character, the task is to check whether the given character is in upper case, lower case, or non-alphabetic character Examples: Input: ch = 'A'Output: A is an UpperCase characterInput: ch = 'a'Output: a is an LowerCase characterInput: ch = '0'Output: 0 is not an alphabetic characterApproach:
      11 min read

    • Average of ASCII values of characters of a given string
      Given a string, the task is to find the average of ASCII values of characters in the string. Examples: Input: str = "for"Output: 109'f'= 102, 'o' = 111, 'r' = 114(102 + 111 + 114)/3 = 109 Input: str = "geeks" Output: 105 Source: Microsoft Internship Experience Approach: Start iterating through chara
      5 min read

    • Sums of ASCII values of each word in a sentence
      We are given a sentence of English language(can also contain digits), we need to compute and print the sum of ASCII values of characters of each word in that sentence. Examples: Input : GeeksforGeeks, a computer science portal for geeksOutput : Sentence representation as sum of ASCII each character
      7 min read

    • Program to find the largest and smallest ASCII valued characters in a string
      Given a string of lowercase and uppercase characters, your task is to find the largest and smallest alphabet (according to ASCII values) in the string. Note that in ASCII, all capital letters come before all small letters. Examples : Input : sample stringOutput : Largest = t, Smallest = aInput : Gee
      6 min read

    • Count characters in a string whose ASCII values are prime
      Given a string S. The task is to count and print the number of characters in the string whose ASCII values are prime. Examples: Input: S = "geeksforgeeks" Output : 3 'g', 'e' and 'k' are the only characters whose ASCII values are prime i.e. 103, 101 and 107 respectively. Input: S = "abcdefghijklmnop
      6 min read

    • Check for ASCII String - Python
      To check if a string contains only ASCII characters, we ensure all characters fall within the ASCII range (0 to 127). This involves comparing each character's value to ensure it meets the criteria. Using str.isascii()The simplest way to do this in Python is by using the built-in str.isascii() method
      2 min read

    • Check if a String Contains Only Alphabets in Java using ASCII Values
      Given a string, now we all know that the task is to check whether a string contains only alphabets. Now we will be iterating character by character and checking the corresponding ASCII value attached to it. If not found means there is some other character other than "a-z" or "A-Z". If we traverse th
      4 min read

    • Map function and Dictionary in Python to sum ASCII values
      We are given a sentence in the English language(which can also contain digits), and we need to compute and print the sum of ASCII values of the characters of each word in that sentence. Examples: Input : GeeksforGeeks, a computer science portal for geeksOutput : Sentence representation as sum of ASC
      2 min read

    • Count of camel case characters present in a given string
      Given a string S, the task is to count the number of camel case characters present in the given string. The camel case character is defined as the number of uppercase characters in the given string. Examples: Input: S = "ckjkUUYII"Output: 5Explanation: Camel case characters present are U, U, Y, I an
      7 min read

    • Sort an array of strings in increasing order of sum of ASCII values of characters
      Given an array arr[] consisting of N strings, the task is to sort the strings in increasing order of the sum of the ASCII (American Standard Code for Information Interchange) value of their characters. Examples: Input: arr[] = {"for", "geeks", "app", "best"}Output: app for best geeksExplanation:Sum
      7 min read

    • Count pairs of characters in a string whose ASCII value difference is K
      Given string str of lower case alphabets and a non-negative integer K. The task is to find the number of pairs of characters in the given string whose ASCII value difference is exactly K. Examples: Input: str = "abcdab", K = 0 Output: 2 (a, a) and (b, b) are the only valid pairs.Input: str = "geeksf
      7 min read

    • Count of alphabets having ASCII value less than and greater than k
      Given a string, the task is to count the number of alphabets having ASCII values less than and greater than or equal to a given integer k. Examples: Input: str = "GeeksForGeeks", k = 90Output:3, 10G, F, G have ascii values less than 90.e, e, k, s, o, r, e, e, k, s have ASCII values greater than or e
      11 min read

    • Count strings having sum of ASCII values of characters equal to a Prime or Armstrong Number
      Given an array arr[] of size N containing strings, the task is to count the number of strings having the sum of ASCII (American Standard Code for Information Interchange) values of characters equal to an Armstrong Number number or a Prime Number. Examples: Input: arr[] = {"hello", "nace"}Output:Numb
      12 min read

    • Make all characters of a string same by minimum number of increments or decrements of ASCII values of characters
      Given a string S of length N, the task is to make all characters of the string the same by incrementing/decrementing the ASCII value of any character by 1 any number of times. Note: All characters must be changed to a character of the original string. Examples: Input: S = "geeks"Output: 20Explanatio
      6 min read

    • Minimize swaps of same-indexed characters to make sum of ASCII value of characters of both the strings odd
      Given two N-length strings S and T consisting of lowercase alphabets, the task is to minimize the number of swaps of the same indexed elements required to make the sum of the ASCII value of characters of both the strings odd. If it is not possible to make the sum of ASCII values odd, then print "-1"
      9 min read

    • Count the number of words having sum of ASCII values less than and greater than k
      Given a string, the task is to count the number of words whose sum of ASCII values is less than and greater than or equal to given k. Examples: Input: str = "Learn how to code", k = 400Output:Number of words having the sum of ASCII less than k = 2Number of words having the sum of ASCII greater than
      11 min read

    • Minimum cost to make the String palindrome using ASCII values
      Given an input string S, the task is to make it a palindrome and calculate the minimum cost for making it a palindrome, where you are allowed to use any one of the following operations any number of times: For replacing the current character with another character the cost will be the absolute diffe
      5 min read

    • Find frequency of each digit 0-9 by concatenating ASCII values of given string
      Given string str, the task is to find the frequency of all digits (0-9) in a string created by concatenating the ASCII values of each character of the given string str. Example: Input: str = "GeeksForGeeks"Output: 7 21 0 0 1 2 0 5 0 0Explanation: The array of ASCII values of all characters of the gi
      5 min read

    • Super ASCII String Checker | TCS CodeVita
      In the Byteland country, a string S is said to super ASCII string if and only if the count of each character in the string is equal to its ASCII value. In the Byteland country ASCII code of 'a' is 1, 'b' is 2, ..., 'z' is 26. The task is to find out whether the given string is a super ASCII string o
      8 min read

geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences