You are here

protected function FeedsExTextEncoder::doConvert in Feeds extensible parsers 7

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 FeedsExTextEncoder::doConvert()
FeedsExTextEncoder::convertEncoding in src/Text/Utility.php
Converts a string to UTF-8.
FeedsExXmlEncoder::convertEncoding in src/Xml/Utility.php
Converts a string to UTF-8.

File

src/Text/Utility.php, line 175
Contains FeedsExEncoderInterface and FeedsExTextEncoder.

Class

FeedsExTextEncoder
Generic text encoder.

Code

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