Beginner's Guide to Coding and Data

Level: Beginner

Unicode explained | Convert characters in Chuck Norris jokes - JavaScript example


expand_more chevron_left


expand_more chevron_left

Decoding the Mysteries of Unicode

Ever wondered how the name Chuck Norris would look in Unicode? Or what Unicode even is? Hold on to your seats because today we're diving deep into the world of character encoding with Unicode. To follow along, we recommend a JavaScript environment ready for some hands-on examples.

We'll be using Observable notebooks for our examples. Observable is a JavaScript environment that allows us to write code and see the results in real time. The notebook can be found here.

What is Unicode?

We've previously explored how computers work with textual data. Now, we're stepping further into how each character is mapped to a unique number through Unicode. We'll be touching upon the following points:

  • Character to Number Mapping
  • Encoding and Decoding
  • Real-world Applications

Before Unicode, various encoding systems existed, making it difficult to achieve consistency. This often led to problems when transferring text between computers. This is where Unicode comes in, providing a universal standard for character representation.

Unicode is a character encoding standard that uses unique numerical values for every character and symbol in most of the world's writing systems. It's a superset of ASCII, which is a character encoding standard for electronic communication.

Encoding Characters with JavaScript

We might think to ask, can we actually see these numerical representations? Absolutely, yes! We can use the charCodeAt method in JavaScript to find out the Unicode value for any character in a string.

// JavaScript code to find Unicode value
let char = 'C';
let code = char.charCodeAt(0);  // Output 67

So if we examine the string Chuck, we find that the Unicode character code for the capital letter C is 67. Intriguing, isn't it?

Decoding Characters

What if we want to reverse the process? How do we get a character back if we have its Unicode value? The String.fromCharCode method does the trick for us.

// JavaScript code to get the character back from Unicode value
let charFromCode = String.fromCharCode(67);  // Output 'C'

We take the number 67 and, using String.fromCharCode, we get back our capital letter C.

When Does Unicode Matter?

Most of the time, we don't have to deal with these underlying numbers. But character encoding becomes crucial when we encounter data transfer issues or read files from various sources. It's always a good practice to keep character encoding in mind for debugging potential issues.

Feel free to play around with the public notebook we've linked in the description. It includes sections for encoding and decoding text in real time. Happy experimenting!


expand_more chevron_left
deeplizard logo DEEPLIZARD Message notifications

Quiz Results


expand_more chevron_left
Unicode provides us with a standard list of unique codes for each character from most of the world's writing systems. 1) The word “Encode” is a verb that means “convert to coded form.” 2) The word “Decode” is a verb that means “convert from coded form.” Let's check it out! Notebook link: Prerequisites: Textual data explained: CLIs Explained: 🕒🦎 VIDEO SECTIONS 🦎🕒 00:00 Welcome to DEEPLIZARD - Go to for learning resources 00:30 Help deeplizard add video timestamps - See example in the description 05:06 Collective Intelligence and the DEEPLIZARD HIVEMIND 💥🦎 DEEPLIZARD COMMUNITY RESOURCES 🦎💥 👋 Hey, we're Chris and Mandy, the creators of deeplizard! 👀 CHECK OUT OUR VLOG: 🔗 💪 CHECK OUT OUR FITNESS CHANNEL: 🔗 🧠 Use code DEEPLIZARD at checkout to receive 15% off your first Neurohacker order: 🔗 ❤️🦎 Special thanks to the following polymaths of the deeplizard hivemind: Mano Prime 👀 Follow deeplizard: Our vlog: Fitness: Facebook: Instagram: Twitter: Patreon: YouTube: 🎓 Deep Learning with deeplizard: AI Art for Beginners - Deep Learning Dictionary - Deep Learning Fundamentals - Learn TensorFlow - Learn PyTorch - Natural Language Processing - Reinforcement Learning - Generative Adversarial Networks - Stable Diffusion Masterclass - 🎓 Other Courses: DL Fundamentals Classic - Deep Learning Deployment - Data Science - Trading - 🛒 Check out products deeplizard recommends on Amazon: 🔗 📕 Get a FREE 30-day Audible trial and 2 FREE audio books using deeplizard's link: 🔗 🎵 deeplizard uses music by Kevin MacLeod 🔗 ❤️ Please use the knowledge gained from deeplizard content for good, not evil.


expand_more chevron_left
deeplizard logo DEEPLIZARD Message notifications

Update history for this page

Did you know you that deeplizard content is regularly updated and maintained?

  • Updated
  • Maintained

Spot something that needs to be updated? Don't hesitate to let us know. We'll fix it!

All relevant updates for the content on this page are listed below.