You are here

public static function StringUtils::getWrapper in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-stdlib/src/StringUtils.php \Zend\Stdlib\StringUtils::getWrapper()

Get the first string wrapper supporting the given character encoding and supports to convert into the given convert encoding.

Parameters

string $encoding Character encoding to support:

string|null $convertEncoding OPTIONAL character encoding to convert in:

Return value

StringWrapperInterface

Throws

Exception\RuntimeException If no wrapper supports given character encodings

4 calls to StringUtils::getWrapper()
Entry::setEncoding in vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Entry.php
Set feed encoding
Entry::__construct in vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Entry.php
Feed::setEncoding in vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Feed.php
Set feed encoding
Feed::__construct in vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Feed.php
Constructor

File

vendor/zendframework/zend-stdlib/src/StringUtils.php, line 125

Class

StringUtils
Utility class for handling strings of different character encodings using available PHP extensions.

Namespace

Zend\Stdlib

Code

public static function getWrapper($encoding = 'UTF-8', $convertEncoding = null) {
  foreach (static::getRegisteredWrappers() as $wrapperClass) {
    if ($wrapperClass::isSupported($encoding, $convertEncoding)) {
      $wrapper = new $wrapperClass($encoding, $convertEncoding);
      $wrapper
        ->setEncoding($encoding, $convertEncoding);
      return $wrapper;
    }
  }
  throw new Exception\RuntimeException('No wrapper found supporting "' . $encoding . '"' . ($convertEncoding !== null ? ' and "' . $convertEncoding . '"' : ''));
}