You are here

protected function ExifPHPExtension::reEncodeToUtf8 in Exif 8

Same name and namespace in other branches
  1. 8.2 src/ExifPHPExtension.php \Drupal\exif\ExifPHPExtension::reEncodeToUtf8()

Encode read value as UTF8 string.

Parameters

string $value: Bytes to encode.

Return value

string encoded value

1 call to ExifPHPExtension::reEncodeToUtf8()
ExifPHPExtension::reformat in src/ExifPHPExtension.php
Helper function to reformat fields where required.

File

src/ExifPHPExtension.php, line 103

Class

ExifPHPExtension
Class ExifPHPExtension Parser implementation base d on PHP Exif extension.

Namespace

Drupal\exif

Code

protected function reEncodeToUtf8($value) {
  $unicode_list = unpack("v*", $value);
  $result = "";
  foreach ($unicode_list as $key => $value) {
    if ($value != 0) {
      $one_character = pack("C", $value);
      $temp = mb_convert_encoding('&#' . $value . ';', 'UTF-8', 'HTML-ENTITIES');
      $result .= $temp;
    }
  }
  return $result;
}