Nicholas C. Zakas![]()
Base64 encoding is a way to represent 8-bit data as 6-bit chunks for lossless data transmission through 7-bit systems. Recently, base64 encoding has become popular for the creation of data URIs. While some browsers natively support base64 encoding and decoding, all browsers don't, and so this utility aims to enable this capability in all browsers.
There are two basic methods, Y.Base64.encode() and Y.Base64.decode(). Each takes a single argument, the string to work on.
Y.Base64.encode() throws an error if there are any non-ASCII characters in the input text as base64 encoding can only be used with characters codes 0-255.
Y.Base64.decode() throws an error if the input string isn't base64 encoded.
<script src="http://yui.yahooapis.com/3.0.0/build/yui/yui-min.js"></script>YUI({
//Last Gallery Build of this module
gallery: 'gallery-2009.12.08-22'
}).use('gallery-base64', function(Y) {
var encodedText = Y.Base64.encode("Hello world!");
var decodedText = Y.Base64.decode(encodedText);
});| Subject | Author | Date |
|---|---|---|
| Encoding non-ascii data | juliannoble | 11/1/10 |
| Is it possible to translate base64? | Myron petersenO | 06/18/11 |
| Re: Encoding non-ascii data | haizaar | 11/21/11 |
© 2006-2011 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info