2013-06-01 14:57:17 -04:00
|
|
|
<?php
|
|
|
|
|
2014-12-23 21:28:26 -05:00
|
|
|
namespace PicoFeed\Encoding;
|
2013-06-01 14:57:17 -04:00
|
|
|
|
2015-03-01 19:56:11 +01:00
|
|
|
/**
|
|
|
|
* Encoding class
|
|
|
|
*
|
|
|
|
* @package Encoding
|
|
|
|
*/
|
2014-05-20 14:20:27 -04:00
|
|
|
class Encoding
|
|
|
|
{
|
2014-05-25 08:47:03 -04:00
|
|
|
public static function convert($input, $encoding)
|
|
|
|
{
|
2015-01-28 21:57:34 -05:00
|
|
|
if ($encoding === 'utf-8' || $encoding === '') {
|
|
|
|
return $input;
|
2014-05-25 08:47:03 -04:00
|
|
|
}
|
2015-01-28 21:57:34 -05:00
|
|
|
|
|
|
|
// convert input to utf-8; ignore malformed characters
|
|
|
|
return iconv($encoding, 'UTF-8//IGNORE', $input);
|
2014-05-25 08:47:03 -04:00
|
|
|
}
|
2013-06-01 14:57:17 -04:00
|
|
|
}
|