Use hold_until_date in item_scheduler.
[order_line_extra.git] / hincludes / lib / StringTools.class.php
1 <?php
2
3 class StringTools {
4         public function __construct(){}
5         static function urlEncode($s) {
6                 return rawurlencode($s);
7         }
8         static function urlDecode($s) {
9                 return urldecode($s);
10         }
11         static function htmlEscape($s) {
12                 return _hx_explode(">", _hx_explode("<", _hx_explode("&", $s)->join("&amp;"))->join("&lt;"))->join("&gt;");
13         }
14         static function htmlUnescape($s) {
15                 return htmlspecialchars_decode($s);
16         }
17         static function startsWith($s, $start) {
18                 return strlen($s) >= strlen($start) && _hx_substr($s, 0, strlen($start)) === $start;
19         }
20         static function endsWith($s, $end) {
21                 $elen = strlen($end);
22                 $slen = strlen($s);
23                 return $slen >= $elen && _hx_substr($s, $slen - $elen, $elen) === $end;
24         }
25         static function isSpace($s, $pos) {
26                 $c = _hx_char_code_at($s, $pos);
27                 return $c >= 9 && $c <= 13 || $c === 32;
28         }
29         static function ltrim($s) {
30                 return ltrim($s);
31         }
32         static function rtrim($s) {
33                 return rtrim($s);
34         }
35         static function trim($s) {
36                 return trim($s);
37         }
38         static function rpad($s, $c, $l) {
39                 return str_pad($s, $l, $c, STR_PAD_RIGHT);
40         }
41         static function lpad($s, $c, $l) {
42                 return str_pad($s, $l, $c, STR_PAD_LEFT);
43         }
44         static function replace($s, $sub, $by) {
45                 return str_replace($sub, $by, $s);
46         }
47         static function hex($n, $digits = null) {
48                 $s = dechex($n);
49                 if($digits !== null) {
50                         $s = str_pad($s, $digits, "0", STR_PAD_LEFT);
51                 }
52                 return strtoupper($s);
53         }
54         static function fastCodeAt($s, $index) {
55                 return ord(substr($s,$index,1));
56         }
57         static function isEOF($c) {
58                 return ($c === 0);
59         }
60         function __toString() { return 'StringTools'; }
61 }