You are here

protected function TextEncoder::doConvert in Feeds extensible parsers 8

Performs the actual encoding conversion.

Parameters

string $data: The data to convert.

string $source_encoding: The detected encoding.

Return value

string The encoded string.

2 calls to TextEncoder::doConvert()
TextEncoder::convertEncoding in src/Encoder/TextEncoder.php
Converts a string to UTF-8.
XmlEncoder::convertEncoding in src/Encoder/XmlEncoder.php
Converts a string to UTF-8.

File

src/Encoder/TextEncoder.php, line 128

Class

TextEncoder
Generic text encoder.

Namespace

Drupal\feeds_ex\Encoder

Code

protected function doConvert($data, $source_encoding) {
  if (in_array(strtolower($source_encoding), self::$utf8Compatible)) {
    return $data;
  }
  $converted = Unicode::convertToUtf8($data, $source_encoding);
  if ($converted === FALSE) {
    return $data;
  }
  return $converted;
}