Urgent.News

What's breaking now, across thousands of outlets.

Tech

Base64 Encode and Decode Without Breaking Emoji and Non-English Text

You have probably met Base64 in the wild: an API token, a data URI in an image tag, a long string pasted into a config file, or an email attachment. It looks like random letters, numbers, + and /, often ending in =. Base64 is not magic. It is a way to represent any bytes as plain, safe text characters so they survive places that only handle text — URLs, JSON, emails, config files. Every 3 bytes…

Base64 encoding and decoding are methods to represent bytes as text characters, allowing them to be safely used in text-based systems like URLs, JSON, emails, and config files. The encoding process converts every 3 bytes into 4 characters, making the output about 33% larger than the input.

However, commonly used functions btoa() and atob() in browsers only handle Latin-1 characters. When these functions encounter emoji or non-English text, they either throw an error or corrupt the result. To avoid this issue, it is recommended to first encode the text as UTF-8, then Base64-encode the resulting bytes.

In modern JavaScript, you can safely encode and decode Unicode text using the following code snippets:

1. Encoding: Create a TextEncoder object, encode the string "Hello 🌍", convert the resulting bytes to a binary string, and then Base64-encode the binary string. The encoded result will be "SGVsbG8g8J+MjQ=".

2. Decoding: Base64-decode the encoded string, convert the resulting binary string to an array of bytes, and then decode those bytes using a TextDecoder. The decoded result will be "Hello 🌍".

For quick encoding or decoding, you can use an online tool that processes text in your browser without installing anything. This tool checks for invalid Base64 input, providing clear errors instead of garbled output. It's essential to note that Base64 is not encryption and should not be used to protect passwords or secrets. It's primarily used for transport and compatibility, not security.

BulkTextKit Pro offers a one-time payment option for bulk processing of up to 50 texts at once, along with saved presets and CSV export. The base tool remains free.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

React: verification states that do explain

A registration form can work perfectly and still leave the user wondering what happened. You click “Submit”, the button spins, an email arrives, and the screen still looks frozen.

Security Tip: Your Outdated WordPress Theme Is an Open Door

Most website owners update their plugins religiously and completely forget their theme. That is a mistake. Your active WordPress theme is code that runs on every single page of your site, and an…

  • Outdated WordPress themes leave sites vulnerable to security risks.
  • Common vulnerabilities include bundled components, abandoned themes, and outdated coding practices.
  • Regularly update themes, back up sites, and remove unused or abandoned themes.

More from Wednesday 28 October →