You are here

public function DocumentTypeBase::convertCharset in Forena Reports 7.5

3 calls to DocumentTypeBase::convertCharset()
CSVDocument::output in src/DocumentFormats/CSVDocument.php
ExcelDocument::output in src/DocumentFormats/ExcelDocument.php
WordDocument::output in src/DocumentFormats/WordDocument.php

File

src/DocumentFormats/DocumentTypeBase.php, line 93
FrxDocument.inc Given a report, render the appropriate output given the document format. @author davidmetzler

Class

DocumentTypeBase

Namespace

Drupal\forena\DocumentFormats

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;
}