In contrast, the atob() function decodes a string that has been encoded using the Base64 format and returns it. It can encode only BMP(Basic Multilingual Plane, U+0000 - U+FFFF). 'ucs2' - 2-bytes, little endian encoded Unicode characters. Many web pages and other document formats use UTF-8. It is conceptually always a two step procedure: convert string to bytes (using some character encoding) encode bytes as Base64. 1 It is therefore not possible to directly encode text as Base64. 'utf8' - Multi byte encoded Unicode characters. Base64 is a binary-to-text encoding, a sequence of bytes is encoded as a sequence of ASCII characters. The btoa() function returns a Base64 encoded ASCII string from a string of binary data, where each character represents an 8-bit byte. This encoding method is very fast, and will strip the high bit if set. This works on almost all modern browsers such as Chrome, Firefox, Safari, Opera, and IE 10+. You can use btoa() and atob() functions, respectively for encoding and decoding Base64 strings. Base64 is commonly used in a number of applications, including email via MIME and storing complex data in XML. This is to ensure that the data remain intact without modification during transport. Each Base64 digit represents exactly 6-bits of data that means 3 bytes can be represented by 4 6-bit Base64 digits.īase64 encoding schemes are commonly used when there is a need to encode binary data that needs to be stored and transferred over media that are designed to deal with textual data. This post will discuss how to encode and decode strings in JavaScript with Base64 format.īase64 is a group of similar binary-to-text encoding schemes representing binary data in an ASCII string format by translating it into a radix-64 representation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |