LZ-based compression algorithm for Haxe.
This is a port of lz-string https://github.com/pieroxy/lz-string. More info about the library can be found here http://pieroxy.net/blog/pages/lz-string/index.html.
This library should run on all Haxe targets. (but is mostly tested in JavaScript and Macro context).
- Haxe 4.0+
Install the library using haxelib
haxelib install lzstring
And add this to your compile arguments / build hxml file
-lib lzstring
Import the library in your code.
import lzstring.LZString;
compress(uncompressed:String):String
compressToBase64(input:String):String
compressToEncodedURIComponent(input:String):String
compressToUint8Array(uncompressed:String):UInt8Array
compressToUTF116(input:String):String
decompress(compressed:String):String
decompressFromBase64(input:String):String
decompressFromEncodedURIComponent(input:String):String
decompressFromUint8Array(compressed:UInt8Array):String
decompressFromUTF116(compressed:String):String
var input = "aaaaabaaaaacaaaaadaaaaaeaaaaaaa";
var l = new LZString();
var compressed = l.compress(input);
trace(compressed); // ↉ࣔ�㠄혅㖈耀
var decompressed = l.decompress(compressed);
trace(decompressed); // aaaaabaaaaacaaaaadaaaaaeaaaaaaa
trace(input == decompressed); // true
var input = "aaaaabaaaaacaaaaadaaaaaeaaaaaaa";
var l = new LZString();
var compressed = l.compressToBase64(input);
trace(compressed); // IYkI1EGNOATWBTWIg===
var decompressed = l.decompressFromBase64(compressed);
trace(decompressed); // aaaaabaaaaacaaaaadaaaaaeaaaaaaa
trace(input == decompressed); // true
Clone the repository and run
haxe test.hxml