Quotes a single identifier (no dot chain separation).

@param string $str The identifier name to be quoted.

@return string The quoted identifier string.
773292
public function quoteSingleIdentifier($str)
    {
        $c = $this->getIdentifierQuoteCharacter();

        return $c . str_replace($c, $c . $c, $str) . $c;
    }
662632
private function toNamespace($str) {
        $stringParts = preg_split('/_+/', $str);

        foreach($stringParts as $key => $stringPart){
            $stringParts[$key] = ucfirst(strtolower($stringPart));
        }
        return implode('\\', $stringParts) . '\\';
    }
835641
static public function fromCamel($str) {
      $str[0] = strtolower($str[0]);
      return preg_replace_callback('/([A-Z])/', function($char) {return "_" . strtolower($char[1]);}, $str);
  }
560879
public static function ucfirst($str)
    {
        switch (AnHelperString::strlen($str)) {
            case 0:
                return '';
            break;
            case 1:
                return AnHelperString::strtoupper($str);
            break;
            default:
                preg_match('/^(.{1})(.*)$/us', $str, $matches);
                return AnHelperString::strtoupper($matches[1]).$matches[2];
            break;
        }
    }
1182403
public static function strrev($str)
    {
        $result = '';
        $strLen = static::length($str);

        if (!$strLen) {
            return $result;
        }

        for ($i = $strLen - 1; $i >= 0; $i--) {
            $result .= static::substr($str, $i, 1);
        }

        return $result;
    }
626318
public function toString($str = '')
    {
        $str .= "<{$this->name} xmlns='{$this->ns}' ";
        foreach ($this->attrs as $key => $value) {
            if ($key !== 'xmlns') {
                $value = htmlspecialchars($value);
                $str .= "$key='$value' ";
            }
        }
        $str .= ">";
        foreach ($this->subs as $sub) {
            $str .= $sub->toString();
        }
        $body = htmlspecialchars($this->data);
        $str .= "$body</{$this->name}>";
        return $str;
    }
1302278
protected function normalize($str)
	{
		$str = str_replace('\"', '$$', trim($str)); // replace slashed quotes
		$str = substr($str, strpos($str, '"') + 1, strlen($str)); // remove first quote
		$str = substr($str, 0, stripos($str, '"')); // remove last quote
		
		return str_replace('$$', '"', $str); // restore replaced quotes
	}
171126
public static function encode(String $str) : String
    {
        $chars = self::$numericalCodes;

        return str_replace(array_keys($chars), array_values($chars), $str);
    }
397220
public function getQuoted($str) : string
    {
        if(
            is_array($str) ||
            is_object($str)
        ) {
            return "'". $this->sanitize(json_encode($str)) ."'";
        } else if(
            is_int($str) ||
            is_float($str)
        ) {
            return (string)$str;
        }

        return "'". $this->sanitize((string)$str) ."'";
    }
16520
protected function strtoupper($str)
    {
        $str = html_entity_decode($str, $this->htmlFuncFlags, self::ENCODING);
        $str = mb_strtoupper($str);
        $str = htmlspecialchars($str, $this->htmlFuncFlags, self::ENCODING);

        return $str;
    }
1072216
public function toBin(string $str):string {
		$this->checkCharacterSet($str);

		// Convert the base32 string back to a binary string
		$str = array_map(function($chr){
			return sprintf('%08b', strpos($this->charset, $chr));
		}, str_split($str));

		// Remove the extra 0's we added
		$str = preg_replace('/000(.{5})/', '$1', implode('', $str));

		// Unpad if nessicary
		$length = strlen($str);
		$rbits = $length&7;

		if($rbits > 0){
			$str = substr($str, 0, $length-$rbits);
		}

		return $str;
	}
1074652
protected function _code($str) {
		$self=$this;
		return preg_replace_callback(
			'/`` (.+?) ``|(?<!\\\\)`(.+?)(?!\\\\)`/',
			function($expr) use($self) {
				return '<code>'.
					$self->esc(empty($expr[1])?$expr[2]:$expr[1]).'</code>';
			},
			$str
		);
	}
635070
public static function decode(String $str) : String
    {
        return preg_replace
        (
            array_keys(self::$scriptTagCharsDecode), 
            array_values(self::$scriptTagCharsDecode), 
            $str
        );
    }
115232
final public static function safeEncodeStr(string $str): string
    {
        return preg_replace_callback('/&#([a-z\d]+);/i', function ($m) {
            $value = (string)$m[0];
            $value = mb_convert_encoding($value, 'UTF-8', 'HTML-ENTITIES');
            return $value;
        }, $str);
    }
462603
protected function escape($str)
    {
        if (is_string($str) OR (is_object($str) && method_exists($str, '__toString'))) {
            return "'".$this->escapeStr($str)."'";
        } elseif (is_bool($str)) {
            return ($str === false) ? 0 : 1;
        } elseif ($str === null) {
            return 'NULL';
        }
        return $str;
    }
701798
private static function escapeString($str)
    {
        if (strlen($str) === 0) {
            return $str;
        }

        $str = str_replace(array(
            "\r",
            "\t",
            "\\",
            "\$",
            "\v",
            "\e",
            "\f",
            "\""
        ), array(
            '\r',
            '\t',
            '\\\\',
            '\$',
            '\v',
            '\e',
            '\f',
            '\"'
        ), $str);

        $str = str_replace("\n", "\\n\"\n\"", $str);

        $result = '';
        $str = str_split($str, 1);
        foreach ($str as $chr) {
            if (!ctype_print($chr) && $chr !== "\n") {
                $result .= '\\' . decoct(ord($chr));
            } else {
                $result .= $chr;
            }
        }
        if (substr($result, -5) === "\\n\"\n\"") {
            $result = substr($result, 0, -5) . "\\n";
        }
        return $result;
    }
1150133
public static String dequote(String str) {
        char start = str.charAt(0);
        if ((start == '\'') || (start == '\"')) {
            // possibly quoted
            char end = str.charAt(str.length() - 1);
            if (start == end) {
                // dequote
                return str.substring(1, str.length() - 1);
            }
        }
        return str;
    }