getEncoding()); } /** * Returns the portion of string specified by the start and length parameters * * @param string $str * @param int $offset * @param int|null $length * @return string|false */ public function substr($str, $offset = 0, $length = null) { return iconv_substr($str, $offset, $length, $this->getEncoding()); } /** * Find the position of the first occurrence of a substring in a string * * @param string $haystack * @param string $needle * @param int $offset * @return int|false */ public function strpos($haystack, $needle, $offset = 0) { return iconv_strpos($haystack, $needle, $offset, $this->getEncoding()); } /** * Convert a string from defined encoding to the defined convert encoding * * @param string $str * @param bool $reverse * @return string|false */ public function convert($str, $reverse = false) { $encoding = $this->getEncoding(); $convertEncoding = $this->getConvertEncoding(); if ($convertEncoding === null) { throw new Exception\LogicException( 'No convert encoding defined' ); } if ($encoding === $convertEncoding) { return $str; } $fromEncoding = $reverse ? $convertEncoding : $encoding; $toEncoding = $reverse ? $encoding : $convertEncoding; // automatically add "//IGNORE" to not stop converting on invalid characters // invalid characters triggers a notice anyway return iconv($fromEncoding, $toEncoding . '//IGNORE', $str); } }