You are here

public function DocumentBase::convertCharset in Forena Reports 8

Perform character set conversion

Parameters

$data:

string $default_encoding:

Return value

string

1 call to DocumentBase::convertCharset()
Excel::flush in src/FrxPlugin/Document/Excel.php
Write the output to disk.

File

src/FrxPlugin/Document/DocumentBase.php, line 103
DocumentBase.inc Given a report, render the appropriate output given the document format. @author davidmetzler

Class

DocumentBase

Namespace

Drupal\forena\FrxPlugin\Document

Code

public function convertCharset($data, $default_encoding = 'UTF-8') {
  if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) {
    $parts = @explode(';', $_SERVER['HTTP_ACCEPT_CHARSET']);
    $parts = @explode(',', $parts[0]);
    $to_encoding = @$parts[0];
  }
  else {
    $to_encoding = $default_encoding;
  }
  if ($to_encoding != 'UTF-8') {
    $this->charset = $to_encoding;
    $data = mb_convert_encoding($data, $to_encoding, 'UTF-8');
  }
  return $data;
}