2022-06-24 12:55:15 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace OCA\Cookbook\Helper;
|
|
|
|
|
2022-06-24 12:58:25 +03:00
|
|
|
/**
|
|
|
|
* This class handles the encoding of downloads in order to only work with UTF8 strings.
|
|
|
|
*/
|
2022-06-24 12:55:15 +03:00
|
|
|
class DownloadEncodingHelper {
|
2022-06-24 12:58:25 +03:00
|
|
|
/**
|
|
|
|
* Encode a string to UTF8
|
|
|
|
*
|
|
|
|
* @param string $data The data to be converted
|
|
|
|
* @param string $encoding The encoding of the input string
|
|
|
|
* @return string The string encoded in UTF8 encoding
|
|
|
|
*/
|
2022-06-24 12:55:15 +03:00
|
|
|
public function encodeToUTF8(string $data, string $encoding): string {
|
|
|
|
$data = iconv($encoding, 'UTF-8', $data);
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
}
|