PhpMimeMailParser\Charset::decodeCharset PHP Method

decodeCharset() public method

public decodeCharset ( $encodedString, $charset )
    public function decodeCharset($encodedString, $charset)
    {
        if (strtolower($charset) == 'utf-8' || strtolower($charset) == 'us-ascii') {
            return $encodedString;
        } else {
            return iconv($this->getCharsetAlias($charset), 'UTF-8//TRANSLIT//IGNORE', $encodedString);
        }
    }

Usage Example

 private function decodeCharset($input)
 {
     if (in_array($this->getCharset(), ['utf-8', 'us-ascii'])) {
         return $input;
     }
     $charset = new Charset();
     return $charset->decodeCharset($input, $this->getCharset());
 }