4 public function __construct(){}
5 static function urlEncode($s) {
6 return rawurlencode($s);
8 static function urlDecode($s) {
11 static function htmlEscape($s) {
12 return _hx_explode(">", _hx_explode("<", _hx_explode("&", $s)->join("&"))->join("<"))->join(">");
14 static function htmlUnescape($s) {
15 return htmlspecialchars_decode($s);
17 static function startsWith($s, $start) {
18 return strlen($s) >= strlen($start) && _hx_substr($s, 0, strlen($start)) === $start;
20 static function endsWith($s, $end) {
23 return $slen >= $elen && _hx_substr($s, $slen - $elen, $elen) === $end;
25 static function isSpace($s, $pos) {
26 $c = _hx_char_code_at($s, $pos);
27 return $c >= 9 && $c <= 13 || $c === 32;
29 static function ltrim($s) {
32 static function rtrim($s) {
35 static function trim($s) {
38 static function rpad($s, $c, $l) {
39 return str_pad($s, $l, $c, STR_PAD_RIGHT);
41 static function lpad($s, $c, $l) {
42 return str_pad($s, $l, $c, STR_PAD_LEFT);
44 static function replace($s, $sub, $by) {
45 return str_replace($sub, $by, $s);
47 static function hex($n, $digits = null) {
49 if($digits !== null) {
50 $s = str_pad($s, $digits, "0", STR_PAD_LEFT);
52 return strtoupper($s);
54 static function fastCodeAt($s, $index) {
55 return ord(substr($s,$index,1));
57 static function isEOF($c) {
60 function __toString() { return 'StringTools'; }