Beginner's Guide to Coding and Data

Level: Beginner

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

video

expand_more chevron_left

text

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!

quiz

expand_more chevron_left
deeplizard logo DEEPLIZARD Message notifications

Quiz Results

resources

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: https://beta.observablehq.com/@deeplizard/encode-and-decode-chuck-norris-jokes-in-unicode Prerequisites: Textual data explained: https://youtu.be/-XLZadCdo9Q CLIs Explained: https://youtu.be/oBP_umJb_2U 🕒🦎 VIDEO SECTIONS 🦎🕒 00:00 Welcome to DEEPLIZARD - Go to deeplizard.com 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: 🔗 https://youtube.com/deeplizardvlog 💪 CHECK OUT OUR FITNESS CHANNEL: 🔗 https://www.youtube.com/channel/UCdCxHNCexDrAx78VfAuyKiA 🧠 Use code DEEPLIZARD at checkout to receive 15% off your first Neurohacker order: 🔗 https://neurohacker.com/shop?rfsn=6488344.d171c6 ❤️🦎 Special thanks to the following polymaths of the deeplizard hivemind: Mano Prime 👀 Follow deeplizard: Our vlog: https://youtube.com/deeplizardvlog Fitness: https://www.youtube.com/channel/UCdCxHNCexDrAx78VfAuyKiA Facebook: https://facebook.com/deeplizard Instagram: https://instagram.com/deeplizard Twitter: https://twitter.com/deeplizard Patreon: https://patreon.com/deeplizard YouTube: https://youtube.com/deeplizard 🎓 Deep Learning with deeplizard: AI Art for Beginners - https://deeplizard.com/course/sdcpailzrd Deep Learning Dictionary - https://deeplizard.com/course/ddcpailzrd Deep Learning Fundamentals - https://deeplizard.com/course/dlcpailzrd Learn TensorFlow - https://deeplizard.com/course/tfcpailzrd Learn PyTorch - https://deeplizard.com/course/ptcpailzrd Natural Language Processing - https://deeplizard.com/course/txtcpailzrd Reinforcement Learning - https://deeplizard.com/course/rlcpailzrd Generative Adversarial Networks - https://deeplizard.com/course/gacpailzrd Stable Diffusion Masterclass - https://deeplizard.com/course/dicpailzrd 🎓 Other Courses: DL Fundamentals Classic - https://deeplizard.com/learn/video/gZmobeGL0Yg Deep Learning Deployment - https://deeplizard.com/learn/video/SI1hVGvbbZ4 Data Science - https://deeplizard.com/learn/video/d11chG7Z-xk Trading - https://deeplizard.com/learn/video/ZpfCK_uHL9Y 🛒 Check out products deeplizard recommends on Amazon: 🔗 https://amazon.com/shop/deeplizard 📕 Get a FREE 30-day Audible trial and 2 FREE audio books using deeplizard's link: 🔗 https://amzn.to/2yoqWRn 🎵 deeplizard uses music by Kevin MacLeod 🔗 https://youtube.com/channel/UCSZXFhRIx6b0dFX3xS8L1yQ ❤️ Please use the knowledge gained from deeplizard content for good, not evil.

updates

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.