Skip to content

Commit 834f209

Browse files
author
Tobias Seipke
committed
Merge pull request #11 from dmclean-celltrak/master
Added files via upload
2 parents 7750d1a + af8b96e commit 834f209

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/LZCompressor/LZString.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,55 @@
33

44
class LZString
55
{
6+
/**
7+
* Compress into a string that is already URI encoded
8+
*
9+
* @param string $input
10+
*
11+
* @return string
12+
*/
13+
public static function compressToEncodedURIComponent($input)
14+
{
15+
if ($input === null) {
16+
return "";
17+
}
18+
return self::_compress(
19+
$input,
20+
6,
21+
function($a) {
22+
return LZUtil::$keyStrUriSafe{$a};
23+
}
24+
);
25+
}
26+
27+
/**
28+
* Decompress from an output of compressToEncodedURIComponent
29+
*
30+
* @param string $input
31+
*
32+
* @return null|string
33+
*/
34+
public static function decompressFromEncodedURIComponent($input)
35+
{
36+
if ($input === null) {
37+
return "";
38+
}
39+
if ($input === "") {
40+
return null;
41+
}
42+
43+
$input = str_replace(' ', "+", $input);
44+
45+
return self::_decompress(
46+
$input,
47+
32,
48+
function($feed, $index) {
49+
return LZUtil::getBaseValue(
50+
LZUtil::$keyStrUriSafe,
51+
LZUtil::utf8_charAt($feed, $index)
52+
);
53+
});
54+
}
655

756
public static function compressToBase64($input)
857
{

0 commit comments

Comments
 (0)