Sets the charset of the search text.

@param string $charset   The charset to use for the search.
@param boolean $convert  Convert existing text values?

@throws Horde_Imap_Client_Exception_SearchCharset
162422
public function charset($charset, $convert = true)
    {
        $oldcharset = $this->_charset;
        $this->_charset = Horde_String::upper($charset);

        if (!$convert || ($oldcharset == $this->_charset)) {
            return;
        }

        foreach (array('and', 'or') as $item) {
            if (isset($this->_search[$item])) {
                foreach ($this->_search[$item] as &$val) {
                    $val->charset($charset, $convert);
                }
            }
        }

        foreach (array('header', 'text') as $item) {
            if (isset($this->_search[$item])) {
                foreach ($this->_search[$item] as $key => $val) {
                    $new_val = Horde_String::convertCharset($val['text'], $oldcharset, $this->_charset);
                    if (Horde_String::convertCharset($new_val, $this->_charset, $oldcharset) != $val['text']) {
                        throw new Horde_Imap_Client_Exception_SearchCharset($this->_charset);
                    }
                    $this->_search[$item][$key]['text'] = $new_val;
                }
            }
        }
    }
732079
public static function setCharSet($charset) {
        self::init();
        if(!self::$_db) {
            self::connect();
        }
        self::$_env->setCharset($charset);
    }
1137879
private function convertToHtmlEntities(string $htmlContent, string $charset = 'UTF-8'): string
    {
        set_error_handler(function () { throw new \Exception(); });

        try {
            return mb_convert_encoding($htmlContent, 'HTML-ENTITIES', $charset);
        } catch (\Exception $e) {
            try {
                $htmlContent = iconv($charset, 'UTF-8', $htmlContent);
                $htmlContent = mb_convert_encoding($htmlContent, 'HTML-ENTITIES', 'UTF-8');
            } catch (\Exception $e) {
            }

            return $htmlContent;
        } finally {
            restore_error_handler();
        }
    }
1176648
public function setCharset($charset)
    {
        $this->clearCachedValueIf($charset != $this->charset);
        $this->charset = $charset;
        if (isset($this->encoder)) {
            $this->encoder->charsetChanged($charset);
        }
    }
114759
public function refreshCharactersetCollation($characterSet, $collation)
    {
        $this->executeQuery('SET NAMES ' . $this->quote($characterSet) . ' COLLATE ' . $this->quote($collation));
        $this->overriddenParams['character_set'] = $characterSet;
        $this->overriddenParams['collation'] = $collation;
    }
276750
public static function toUtf8($content, $charset)
    {
        $charset = strtoupper($charset);

        if (empty($charset) || $charset === 'UTF-8') {
            return $content;
        }

        $encodings = array_map('strtoupper', mb_list_encodings());

        if (in_array($charset, $encodings, true)) {
            return mb_convert_encoding($content, 'UTF-8', $charset);
        }

        if (function_exists('iconv')) {
            return iconv($charset, 'UTF-8//TRANSLIT//IGNORE', $content);
        }

        return $content;
    }
698542
public function setCharset($charset)
    {
        $this->setHeaderParameter('Content-Type', 'charset', $charset);
        if ($charset !== $this->userCharset) {
            $this->clearCache();
        }
        $this->userCharset = $charset;
        parent::charsetChanged($charset);

        return $this;
    }
1059756
public function isAcceptCharset($charset)
    {
        if ($this->hasHeader('Accept-Charset')) {
            return $this->isAccept($this->getHeader('Accept-Charset'), $charset);
        }
        return false;
    }
733083
public function charset($charset = null)
    {
        deprecationWarning(
            'Response::charset() is deprecated. ' .
            'Use getCharset()/withCharset() instead.'
        );

        if ($charset === null) {
            return $this->_charset;
        }
        $this->_charset = $charset;
        $this->_setContentType();

        return $this->_charset;
    }
529711
public static function GetMimeTypeCharsetByCharset ($charset) {
		$charset_map = static::GetCharsetMapForMimeType();
		return isset($charset_map[$charset]) ? $charset_map[$charset] : null;
	}
273596
public Charset setCharset(Charset charset) {
        Charset prev = this.charset.get();
        this.charset.set(charset);
        return prev;
    }
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;
    }
110039
public function setInputCharset($charset)
    {
        $flag = true;
        
        $charset  = strtolower($charset);
        $charsets = array('utf-8', 'windows-1256', 'cp1256', 'iso-8859-6');
        
        if (in_array($charset, $charsets)) {
            if ($charset == 'windows-1256') {
                $charset = 'cp1256';
            }
            $this->_inputCharset = $charset;
        } else {
            $flag = false;
        }
        
        return $flag;
    }
563033
public function setEncoding($encoding, $convertEncoding = null)
    {
        $supportedEncodings = static::getSupportedEncodings();

        $encodingUpper = strtoupper($encoding);
        if (!in_array($encodingUpper, $supportedEncodings)) {
            throw new Exception\InvalidArgumentException(
                'Wrapper doesn\'t support character encoding "' . $encoding . '"'
            );
        }

        if ($encodingUpper !== strtoupper($convertEncoding)) {
            $this->convertEncoding = $encodingUpper;
        }

        if ($convertEncoding !== null) {
            if ($encodingUpper !== strtoupper($convertEncoding)) {
                throw new Exception\InvalidArgumentException(
                    'Wrapper doesn\'t support to convert between character encodings'
                );
            }

            $this->convertEncoding = $encodingUpper;
        } else {
            $this->convertEncoding = null;
        }
        $this->encoding = $encodingUpper;

        return $this;
    }
359391
public void setCharset(final String charset) {
		try {
			this.charset = Charset.forName(charset);
		} catch (UnsupportedCharsetException ex) {
			this.charset = StandardCharsets.UTF_8;
			LOG.error("The specified character set could not be converted to {}. Set the default character set({}).",
					charset, this.charset);
		}
	}
847305
function setCharset($charset) {
        $locale = setlocale(LC_CTYPE, 0);
        setlocale(LC_CTYPE, 'en_US');
        $this->_charset = strtolower($charset);
        setlocale(LC_CTYPE, $locale);
    }
41233
public function setCharset($charset = 'UTF8', \PDO $db)
    {
        try {
            if (empty($charset) || !$db) {
                throw new DatabaseException(__METHOD__ . "\ncharset:$charset\nressource:" . print_r($this->db, true), self::ERR_EXEC, self::SEVERITY_LOG, __FILE__, __LINE__);
            }

            $this->mysqli_client_encoding = (string)$charset;

            if ($this->db_detail) {
                $this->db_detail->character_set_client = (string)$charset;
            }
        } catch (DatabaseException $e) {
            throw $e;
        }

        $db->exec("set names $charset");

        return true;
    }