3 * @file src/Util/Strings.php
6 namespace Friendica\Util;
9 * @brief This class contains methods to modify/transform strings.
14 * escape text ($str) for XML transport
16 * @return string Escaped text.
18 public static function escape($str)
20 $buffer = htmlspecialchars($str, ENT_QUOTES, "UTF-8");
21 $buffer = trim($buffer);
28 * @param string $s xml escaped text
29 * @return string unescaped text
31 public static function unescape($s)
33 $ret = htmlspecialchars_decode($s, ENT_QUOTES);
38 * apply escape() to all values of array $val, recursively
42 public static function arrayEscape($val)
45 return $val?"true":"false";
46 } elseif (is_array($val)) {
47 return array_map('Strings::arrayEscape', $val);
49 return self::escape((string) $val);