You are here

protected function FeedsExTextEncoder::detectEncoding in Feeds extensible parsers 7

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 FeedsExTextEncoder::detectEncoding()
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 154
Contains FeedsExEncoderInterface and FeedsExTextEncoder.

Class

FeedsExTextEncoder
Generic text 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);
}