ƒ.encoding - Get-Kraken/fixx GitHub Wiki
Feature test
ƒ.encoding.caniuse.JSON(); // → true || false
ƒ.encoding.caniuse.Base64(); // → true || false
Base64 encoding/decoding
ƒ.encoding.Base64.encode('string'); // → "c3RyaW5n"
ƒ.encoding.Base64.decode('c3RyaW5n'); // → "string"
Note: native Base64 encoding and decoding is not supported in IE9 and lower. Use a shim for versions 9 and lower of Internet Explorer. http://caniuse.com/#feat=atob-btoa
ƒ.encoding.data
Package and unpackage data (objects)
ƒ.encoding.data.pack({foo:'foo', bar:'bar'});
// → "eyJmb28iOiJmb28iLCJiYXIiOiJiYXIifQ=="
ƒ.encoding.data.unpack('eyJmb28iOiJmb28iLCJiYXIiOiJiYXIifQ==');
// → "{foo:'foo', bar:'bar'}"
Note: when using this to pass data over URLs, be aware of the maximum url length of 2048 characters (for most modern browsers)
ƒ.encoding.convert
xmlToJson
Used to convert XML data to JSON.
Example:
$.get('http://m.highways.gov.uk/feeds/rss/AllEvents.xml', function(data){
console.info(ƒ.encoding.convert.xmlToJson(data));
});