function drupal_convert_to_utf8

Converts data to UTF-8.

Parameters

string $data: The data to be converted.

string $encoding: The encoding that the data is in.

Return value

string|bool Converted data or FALSE.

See also

\Drupal\Component\Utility\Unicode::convertToUtf8().

1 call to drupal_convert_to_utf8()
drupal_xml_parser_create in drupal/core/includes/unicode.inc
Prepares a new XML parser.

File

drupal/core/includes/unicode.inc, line 131
Provides Unicode-related conversions and operations.

Code

function drupal_convert_to_utf8($data, $encoding) {
  $out = Unicode::convertToUtf8($data, $encoding);
  if ($out === FALSE) {
    watchdog('php', 'Unsupported encoding %s. Please install iconv, GNU recode or mbstring for PHP.', array(
      '%s' => $encoding,
    ), WATCHDOG_ERROR);
  }
  return $out;
}