Make sure that string is never empty.

@param string $sInput   string that will be replaced
@param string $sReplace string that will replace

@return string
325987
public function assureContent($sInput, $sReplace = null)
    {
        $oStr = getStr();
        if (!$oStr->strlen($sInput)) {
            if (!isset($sReplace) || !$oStr->strlen($sReplace)) {
                $sReplace = "-";
            }
            $sInput = $sReplace;
        }

        return $sInput;
    }
1323636
public static function varToString($input, $indent = '')
	{
		switch (gettype($input))
		{
			case 'string':
				return "'" . str_replace(array("\\", "'"), array("\\\\", "\\'"), $input) . "'";
			case 'array':
				$output = "array(\r\n";
				foreach ($input as $key => $value)
				{
					$output .= $indent . "\t" . self::varToString($key, $indent . "\t") . ' => ' . self::varToString(
						$value, $indent . "\t");
					$output .= ",\r\n";
				}
				$output .= $indent . ')';
				return $output;
			case 'boolean':
				return $input ? 'true' : 'false';
			case 'NULL':
				return 'NULL';
			case 'integer':
			case 'double':
			case 'float':
				return "'" . (string) $input . "'";
		}
		return 'NULL';
	}
1305240
public function canonicalize($input)
    {
        $strippedInput = str_replace(' ', '', $input);
        if (!preg_match('/^\d{4}[A-Za-z]{2}$/', $strippedInput)) {
            return $input;
        }

        return implode(' ', [substr($strippedInput, 0, 4), mb_strtoupper(substr($strippedInput, -2, 2))]);
    }
892323
function replaceCI($search, $replace, $subject, $count = null) {
		if (!is_array($search)) {
			$slen = mb_strlen($search);
			if (0 === $slen) {
				return $subject;
			}
			$lendif = mb_strlen($replace) - mb_strlen($search);
			$search = mb_strtolower($search);
			$search = preg_quote($search);
			$lstr = mb_strtolower($subject);
			$i = 0;
			$matched = 0;
			/** @var string[] $matches */
			$matches = [];
			while (1 === preg_match('/(.*)'.$search.'/Us',$lstr, $matches)) {
				if ($i === $count ) {
					break;
				}
				$mlen = mb_strlen($matches[0]);
				$lstr = mb_substr($lstr, $mlen);
				$subject =
					substr_replace(
						$subject, $replace, $matched+strlen($matches[1]), $slen
					)
				;
				$matched += $mlen + $lendif;
				$i++;
			}
			return $subject;
		}
		else {
			foreach (array_keys($search) as $k ) {
				if (is_array($replace)) {
					if (array_key_exists($k,$replace)) {
						$subject = $this->replaceCI($search[$k], $replace[$k], $subject, $count);
					}
					else {
						$subject = $this->replaceCI($search[$k], '', $subject, $count);
					}
				} else {
					$subject = $this->replaceCI($search[$k], $replace, $subject, $count);
				}
			}
			return $subject;
		}
	}
865806
public function gsub($pattern, $replacement)
    {
        $pattern = new String($pattern);

        if ($pattern->isRegexp()) {
            return new String(preg_replace($pattern, $replacement, $this));
        } else {
            return new String(str_replace($pattern, $replacement, $this));
        }
    }
586555
public static String utf2string(byte[] src, int sindex, int len) {
        char dst[] = new char[len];
        int len1 = utf2chars(src, sindex, dst, 0, len);
        return new String(dst, 0, len1);
    }
1149146
public static function asciify(string $input, string $language = 'en', bool $removeUnsupported = true): string {
    $output = S::toAscii($input, $language, $removeUnsupported);

    return $output;
  }
807055
public function prepareCSVField($sInField)
    {
        $oStr = getStr();
        if ($oStr->strstr($sInField, '"')) {
            return '"' . str_replace('"', '""', $sInField) . '"';
        } elseif ($oStr->strstr($sInField, ';')) {
            return '"' . $sInField . '"';
        }

        return $sInField;
    }
733148
protected function validate($input)
    {
        if (true === is_string($input)) {
            $input = @json_decode($input, true);
            if (json_last_error() !== JSON_ERROR_NONE) {
                $input = false;
            }
        }

        return $input;
    }
1280544
protected void format (@Nonnull final JSFormatter aFormatter, @Nonnull final String sIndent)
  {
    if (!isEmpty ())
      aFormatter.plain (sIndent);

    final Iterator <Object> aIter = iterator ();
    while (aIter.hasNext ())
    {
      final Object aValue = aIter.next ();

      if (aValue instanceof String)
      {
        int nIdx;
        String sValue = (String) aValue;
        while ((nIdx = sValue.indexOf ('\n')) != -1)
        {
          final String sLine = sValue.substring (0, nIdx);
          if (sLine.length () > 0)
            aFormatter.plain (_escape (sLine));
          sValue = sValue.substring (nIdx + 1);
          aFormatter.nlFix ().plain (sIndent);
        }
        if (sValue.length () != 0)
          aFormatter.plain (_escape (sValue));
      }
      else
        if (aValue instanceof AbstractJSClass)
        {
          ((AbstractJSClass) aValue).printLink (aFormatter);
        }
        else
          if (aValue instanceof AbstractJSType)
          {
            aFormatter.generatable ((AbstractJSType) aValue);
          }
          else
            throw new IllegalStateException ("Unsupported value: " + aValue);
    }

    if (!isEmpty ())
      aFormatter.nlFix ();
  }
1233782
protected function _jsonEncode($in, $indent = 0)
    {
        $out = '';

        foreach ($in as $key => $value) {

            $out .= str_repeat("    ", $indent + 1);
            $out .= json_encode((string)$key) . ': ';

            if (is_object($value) || is_array($value)) {
                $out .= $this->_jsonEncode($value, $indent + 1);
            } else {
                $out .= json_encode($value);
            }

            $out .= "," . PHP_EOL;
        }

        if (!empty($out)) {
            $out = substr($out, 0, -2);
        }

        $out = "{" . PHP_EOL . $out . PHP_EOL . str_repeat("    ", $indent) . "}";

        return $out;
    }
904915
function(sInput, levels, indentString) {
		var indentedLineBreak;

		indentString = indentString || '\t';
		indentedLineBreak = '\n'+ ( new Array( levels + 1 ).join( indentString ) );

		return indentedLineBreak + sInput.split('\n').join(indentedLineBreak);
	}
289015
public function prepareCSV($sInput)
    {
        $sInput = \OxidEsales\Eshop\Core\Registry::getUtilsString()->prepareCSVField($sInput);

        return str_replace(["&nbsp;", "&euro;", "|"], [" ", "", ""], $sInput);
    }
1030478
function encodeSubject($input, $charset = 'ISO-8859-1')
  {
    // set the internal encoding to the encoding of the given input
    // this way no conversion is done, because we only need the 'Q' encoding
    $old_enc=mb_internal_encoding();
    mb_internal_encoding($charset);
    $output=mb_encode_mimeheader($input,$charset, 'Q', $this->LE);
    // and when ready, restore the internal encoding again
    mb_internal_encoding($old_enc);
    return $output;
    // below is a fallback mechanism which seems to work also
    /*
    preg_match_all('/(\\w*[\\x80-\\xFF]+\\w*)/', $input, $matches);
    foreach ($matches[1] as $value) {
      $replacement = preg_replace('/([\\x80-\\xFF])/e', '"=" . strtoupper(dechex(ord("\\1")))', $value);
      $input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input);
    }
    return $input;
    */
  }
610295
public function replaceBy($sContent, $sOptionToUnescape = '"html"', $sEncoding = '"UTF-8"') {

		$sOptionToUnescape = str_replace("'", '"', $sOptionToUnescape);
		$sEncoding = str_replace("'", '"', $sEncoding);

		if ($sOptionToUnescape === '"htmlall"') {

			return '{html_entity_decode('.$sContent.', ENT_COMPAT | ENT_HTML401, '.$sEncoding.')}';
		}
		else {

			return '{htmlspecialchars_decode('.$sContent.', ENT_COMPAT | ENT_HTML401)}';
		}
	}
39886
public final static function prepend(string $source, array $Prepend): string {
		return self::encode(Arr::prepend(self::decode($source), $Prepend));
	}
227076
public static function toString($input = false) {

        if ($input) {

            $string = (string) $input;
            if (Validate::isString($string)) {

                return $string;
            }
        }

        return false;
    }