Sets the environment encoding of the referencing (!) document, e.g. if defined in a link tag of an HTML page.
This is used as a fall back value to determine the charset of the CSS file.

@param string $encoding
@return $this
964364
public function setEnvironmentEncoding($encoding)
    {
        if (is_string($encoding)) {
            if (in_array($encoding, mb_list_encodings())) {
                $this->environmentEncoding = $encoding;
            } else {
                throw new \InvalidArgumentException(
                    "Invalid value '" . $encoding . "' for argument 'encoding' given. Encoding not supported."
                );
            }
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($encoding). "' for argument 'encoding' given."
            );
        }

        return $this;
    }
1051660
private function utf8ToCharset($content, $encoding = null)
    {
        if ('UTF-8' !== $encoding && !empty($encoding)) {
            if (function_exists('mb_convert_encoding')) {
                return mb_convert_encoding($content, $encoding, 'UTF-8');
            }

            if (function_exists('iconv')) {
                return iconv('UTF-8', $encoding, $content);
            }

            throw new \RuntimeException('No suitable convert encoding function (use UTF-8 as your encoding or install the iconv or mbstring extension).');
        }

        return $content;
    }
522316
protected String setEncoding(String content, String encoding) {

        if (content.toLowerCase().indexOf("<?xml") == -1) {
            return content;
        } else {
            // XML information present, replace encoding
            // set the encoding only if it does not exist
            String xmlTag = content.substring(0, content.indexOf(">") + 1);
            if (xmlTag.toLowerCase().indexOf("encoding") == -1) {
                content = content.substring(content.indexOf(">") + 1);
                content = "<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>" + content;
            }
        }
        return content;
    }
275779
public function setLanguage($language)
    {
        $this->setLocale($language);

        $code = $this->getLanguageCode($language);

        putenv('LC_ALL=' . $code);
        setlocale(LC_ALL, $code);
        setlocale(LC_NUMERIC, 'en_US');

        return $this;
    }
559835
public function setCharset($charset)
    {
        $prev = $this->charset;

        $charset = strtoupper($charset);
        $charset = null === $charset || 'UTF-8' === $charset || 'UTF8' === $charset ? 'CP1252' : $charset;

        $this->charset = $charset;

        return $prev;
    }
1067692
public function lower($encoding = null)
    {
        if (!$this->hasMbstring()) {
            return $this->transform('\strtolower');
        }

        $encoding = $this->encoding($encoding);

        return $this->transform('\mb_convert_case', MB_CASE_LOWER, $encoding);
    }
895067
protected function startDocument($encoding)
    {
        $xmlWriter = new \XMLWriter();
        $xmlWriter->openMemory();
        $xmlWriter->startDocument('1.0', $encoding);

        return $xmlWriter;
    }
472919
public function charset($charset = null)
    {
        if (!func_num_args()) {
            return $this->_stream->charset();
        }
        $this->_stream->charset($charset);
        return $this;
    }
676907
public function getQuery($encoding)
    {
        /**
 * Zend_Search_Lucene_Search_Query_Preprocessing_Phrase 
*/
        include_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Phrase.php';
        $query = new Zend_Search_Lucene_Search_Query_Preprocessing_Phrase(
            $this->_phrase,
            $encoding,
            ($this->_field !== null)?
                                                                              iconv($encoding, 'UTF-8', $this->_field) :
            null
        );

        if ($this->_proximityQuery) {
            $query->setSlop($this->_wordsDistance);
        }

        $query->setBoost($this->_boost);

        return $query;
    }
1371499
public function setEncoding($encoding = null)
    {
        if ($encoding !== null) {
            $orig = PHP_VERSION_ID < 50600
                        ? iconv_get_encoding('internal_encoding')
                        : ini_get('default_charset');
            if (PHP_VERSION_ID < 50600) {
                $result = iconv_set_encoding('internal_encoding', $encoding);
            } else {
                $result = @ini_set('default_charset', $encoding);
            }
            if (!$result) {
                require_once 'Zend/Validate/Exception.php';
                throw new Zend_Validate_Exception('Given encoding not supported on this OS!');
            }

            if (PHP_VERSION_ID < 50600) {
                iconv_set_encoding('internal_encoding', $orig);
            } else {
                @ini_set('default_charset', $orig);
            }
        }

        $this->_encoding = $encoding;
        return $this;
    }
299293
public function setEncoding($encoding)
    {
        if (empty($encoding))
            throw new \InvalidArgumentException('The encoding may not be empty or NULL.');
        if (!is_string($encoding))
            throw new \InvalidArgumentException('The encoding must be a string.');

        $this->encoding = $encoding;

        return $this;
    }
1042257
public function isAcceptEncoding($encoding)
    {
        if ($this->hasHeader('Accept-Encoding')) {
            return $this->isAccept($this->getHeader('Accept-Encoding'), $encoding);
        }
        return false;
    }
53677
public function setContentTransferEncoding($encoding)
    {
        switch ($encoding) {
            case '7bit':
                $encoder = \Swift_Encoding::get7BitEncoding();
                break;

            case '8bit':
                $encoder = \Swift_Encoding::get8BitEncoding();
                break;

            case 'base64':
                $encoder = \Swift_Encoding::getBase64Encoding();
                break;

            case 'qp':
                $encoder = \Swift_Encoding::getQpEncoding();
                break;

            default:
                throw new SwiftMailerException('Invalid encoding name provided.
												Valid encodings are [7bit, 8bit, base64, qp].'
                );
                break;
        }

        $this->message->setEncoder($encoder);

        return $this;
    }
122718
public static function PurifyTXT($html = null, $encoding = 'UTF-8') {
		
		$config = self::GetHTMLPurifierConfig();
		$config->set('Core.Encoding', $encoding);
		$config->set('HTML.Allowed', null); // Allow Nothing
		$config->set('HTML.AllowedElements', array());
		$purifier = new \HTMLPurifier($config);
		return $purifier->purify($html);
	}
271372
public function setLanguage($language)
	{
        if (! $this->exists($language)) {
            $language = $this->_default;
        }

        $this->_language = $language;
        $this->_meta = $this->getMetadata($this->_language);
        $local = $this->getLocale();
        setlocale(LC_TIME, $local);

		return $this;
	}
870627
public void setCharacterEncoding(String encoding)
    {
        if (this._outputState==0 && !isCommitted())
        {
            _charEncodingSetInContentType=true;
            _httpResponse.setCharacterEncoding(encoding,true);
        }
    }
1048624
public function setHeaderEncoding($encoding)
    {
        $allowed = array(
            Zend_Mime::ENCODING_BASE64,
            Zend_Mime::ENCODING_QUOTEDPRINTABLE
        );
        if (!in_array($encoding, $allowed)) {
            /**
             * @see Zend_Mail_Exception
             */
            // require_once 'Zend/Mail/Exception.php';
            throw new Zend_Mail_Exception('Invalid encoding "' . $encoding . '"');
        }
        $this->_headerEncoding = $encoding;

        return $this;
    }