Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • 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
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App
Next Article:
JavaScript Application - Get Unicode Character Value
Next article icon

JavaScript Application - Get Unicode Character Value

Last Updated : 06 Jan, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

A Unicode Character Value is a unique numeric identifier assigned to every character in the Unicode standard. It allows consistent text representation in computers, regardless of the platform, device, or language.

What We Are Going to Create

We will build a simple web application where users can input a single character to retrieve its Unicode Character Value.

  • The UI will be simple, with flexible layouts for various screen sizes.
  • A field where the user can type in a word or phrase.
  • A button that, when clicked, triggers the display of Unicode character values.
  • The result area will show the Unicode values of the characters entered by the user.

Project Preview

Unicode
JavaScript Application To Check Unicode Character Value

Unicode Character Value - HTML & CSS Structure

This structure provides a simple web interface with an input field to enter a number and a button to check Unicode Character Value.

HTML
<html> <head>     <style>         body {             margin: 0;             padding: 0;             font-family: Arial, sans-serif;             background: linear-gradient(to right, #6a11cb, #2575fc);             color: #fff;             display: flex;             justify-content: center;             align-items: center;             height: 100vh;         }         .container {             text-align: center;             background: #ffffff1a;             border-radius: 12px;             padding: 20px;             width: 90%;             max-width: 400px;             box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.2);         }         h1 {             font-size: 24px;             margin-bottom: 20px;         }         input[type="text"] {             width: 80%;             padding: 10px;             border: none;             border-radius: 6px;             margin-bottom: 15px;             font-size: 16px;             text-align: center;         }         input::placeholder {             color: #ccc;         }         button {             background-color: #2575fc;             color: white;             border: none;             padding: 10px 20px;             border-radius: 6px;             cursor: pointer;             font-size: 16px;             transition: background-color 0.3s ease;         }         button:hover {             background-color: #1b5bbf;         }         #output {             margin-top: 20px;             font-size: 18px;             font-weight: bold;         }     </style> </head> <body>     <div class="container">         <h1>Unicode Character Value Finder</h1>         <label for="charInput">Enter a character:</label>         <input type="text" id="charInput" maxlength="2" placeholder="e.g., A or 😊">         <button id="getUnicode">Get Unicode Value</button>         <p id="output"></p>     </div> </body> </html> 

In this example

  • body: Uses Flexbox to center content both vertically and horizontally, with a gradient background and no margins/padding.
  • .container: A card-like box with rounded corners, padding, and a subtle shadow.
  • h1: Large title with space below it.
  • input: Easy-to-use text field with padding, rounded corners, and centered text.
  • input::placeholder: Light gray placeholder text.
  • button: Blue button with white text, rounded corners, and a hover effect for interactivity.
  • output: Bold and larger font for the result, with space above it.

Unicode Character Value - JavaScript Functionality

The JavaScript function retrieves the user input as a character from an input field. It then checks if the input is empty and displays an error message if so. The function uses the codePointAt(0) method to determine the Unicode value of the character.

JavaScript
document.getElementById('getUnicode').addEventListener('click', function () {     const input = document.getElementById('charInput').value;     if (input.length === 0) {         document.getElementById('output').textContent = "Please enter a character.";         return;     }     const Value = input.codePointAt(0);     document.getElementById('output').textContent =         `The Unicode value of "${input}" is: ${Value}`; }); 

In this example

  • The function gets the user input as a character from the input field with the ID characterInput.
  • It checks if the input is empty (length is 0). If empty, it displays an error message (“Please enter a character”) in the element with the ID output.
  • If the input is valid, it uses input. codePointAt(0) to retrieve the Unicode value of the first character.
  • The function updates the content of the element with the ID output to show the Unicode value of the entered character, in the format.

Complete Code

HTML
<html> <head>     <style>         body {             margin: 0;             padding: 0;             font-family: Arial, sans-serif;             background: linear-gradient(to right, #6a11cb, #2575fc);             color: #fff;             display: flex;             justify-content: center;             align-items: center;             height: 100vh;         }         .container {             text-align: center;             background: #ffffff1a;             border-radius: 12px;             padding: 20px;             width: 90%;             max-width: 400px;             box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.2);         }         h1 {             font-size: 24px;             margin-bottom: 20px;         }         input[type="text"] {             width: 80%;             padding: 10px;             border: none;             border-radius: 6px;             margin-bottom: 15px;             font-size: 16px;             text-align: center;         }         input::placeholder {             color: #ccc;         }         button {             background-color: #2575fc;             color: white;             border: none;             padding: 10px 20px;             border-radius: 6px;             cursor: pointer;             font-size: 16px;             transition: background-color 0.3s ease;         }         button:hover {             background-color: #1b5bbf;         }         #output {             margin-top: 20px;             font-size: 18px;             font-weight: bold;         }     </style> </head> <body>     <div class="container">         <h1>Unicode Character Value Finder</h1>         <label for="charInput">Enter a character:</label>         <input type="text" id="charInput" maxlength="100" placeholder="e.g., A or 😊">         <button id="getUnicode">Get Unicode Value</button>         <p id="output"></p>     </div>     <script>         document.getElementById('getUnicode').addEventListener('click', function () {             const input = document.getElementById('charInput').value;             if (input.length === 0) {                 document.getElementById('output').textContent = "Please enter a character.";                 return;             }             const Value = input.codePointAt(0);             document.getElementById('output').textContent =                 `The Unicode value of "${input}" is: ${Value}`;         });     </script> </body> </html> 

Next Article
JavaScript Application - Get Unicode Character Value

T

tanmxcwi
Improve
Article Tags :
  • HTML
  • JavaScript-Projects

Similar Reads

    HTML | KeyboardEvent which Property
    The KeyboardEvent which property is used for returning the Unicode character code of the key which triggers the onkeypress event. It also returns the Unicode key code of the key that triggered the onkeydown or onkeyup event. The key code is a number which represents an actual key on the keyboard, un
    1 min read
    Java Program to Determine the Unicode Code Point at Given Index in String
    ASCII is a code that converts the English alphabets to numerics as numeric can convert to the assembly language which our computer understands. For that, we have assigned a number against each character ranging from 0 to 127. Alphabets are case-sensitive lowercase and uppercase are treated different
    5 min read
    Java.lang.Character.UnicodeBlock Class in Java
    Character.UnicodeBlock Class represents particular Character blocks of the Unicode(standards using hexadecimal values to express characters - 16 bit) specifications. Character Blocks define characters used for specific purpose. Declaration : public static final class Character.UnicodeBlock extends C
    2 min read
    Get Unicode Character Value in JavaScript
    Here are various ways to get Unicode character values in JavaScript 1. Using charCodeAt() to Get Unicode ValuesThis code defines a string letter containing the character "A". It then uses the charCodeAt() method to get the Unicode value of the first character (index 0) and logs the result, which is
    5 min read
    Java String codePointAt() Method
    The codePointAt() method in Java is part of the String class. It is used to return the Unicode value of the character at the specified index in the string. This method is very useful when working with characters beyond the Basic Multilingual Plane (BMP), such as emojis or special symbols.Example 1:
    3 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