You are here

protected function TextEncoder::detectEncoding in Feeds extensible parsers 8

Detects the encoding of a string.

Parameters

string $data: The string to guess the encoding for.

Return value

string|bool Returns the encoding, or false if one could not be detected.

2 calls to TextEncoder::detectEncoding()
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 107

Class

TextEncoder
Generic text encoder.

Namespace

Drupal\feeds_ex\Encoder

Code

protected function detectEncoding($data) {
  if (!$this->isMultibyte) {
    return FALSE;
  }
  if ($detected = mb_detect_encoding($data, $this->encodingList, TRUE)) {
    return $detected;
  }
  return mb_detect_encoding($data, $this->encodingList);
}