Sets the chunker's character encoding

@param  string|null  $encoding  the chunker's character encoding
@throws  InvalidArgumentException  if $encoding is not an supported charset;
the special string 'auto'; or, null
@since  0.1.0
481842
public function setEncoding($encoding)
	{
		if ( ! is_string($encoding) || ! in_array($encoding, mb_list_encodings())) {
			throw new \InvalidArgumentException(
				__METHOD__."() expects parameter one, encoding, to be a valid "
				 . "character encoding name"
			);
		}
		
		$this->encoding = $encoding;
		
		return $this;
	}
876873
public static function lower(string $str, string $encoding = null) : string
    {
        return mb_strtolower($str, $encoding ?: utils\Str::encoding($str));
    }
1297527
public function toString(string $encoding='utf8')
    {
        $output = '';
        $input = $this->data;

        switch ($encoding) {
            case 'hex':
            foreach ($input as $data)  {
                $hex = dechex($data);

                // pad zero
                if ((strlen($hex) % 2) !== 0) {
                    $hex = '0' . $hex;
                }
                $output .= $hex;
            }
            break;
            case 'ascii':
            foreach ($input as $data)  {
                $output .= chr($data);
            }
            break;
            case 'utf8':
            // $length = count($input);

            // for ($i = array_keys($input)[0]; $i < $length; $i += 3) {
            //     $output .= chr($input[$i]) . chr($input[$i + 1]) . chr($input[$i + 2]);
            // }
            // change to bytes string
            foreach ($input as $data)  {
                $output .= chr($data);
            }
            break;
            default:
            throw new InvalidArgumentException('ToString encoding must be valid.');
            break;
        }
        return $output;
    }
1292572
public function ensurePrefix($substring, $encoding = null)
    {
        if (!$this->hasMbstring()) {
            $len = \strlen($substring);
            if (\substr($this->string, 0, $len) == $substring) {
                return $this;
            }
        } else {
            $encoding = $this->encoding($encoding);
            $len = \mb_strlen($substring, $encoding);
            if (\mb_substr($this->string, 0, $len, $encoding) == $substring) {
                return $this;
            }
        }

        return $this->prefix($substring);
    }
914338
public static function setContentType($contentType, $encoding = null) {
		$value = $contentType;
		if (isset ( $encoding ))
			$value .= ' ;charset=' . $encoding;
		self::header ( 'Content-Type', $value );
	}
140158
protected void setDefaultEncoding(String encoding) {

        m_defaultEncoding = encoding.intern();
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.LOG_SET_DEFAULT_ENCODING_1, m_defaultEncoding));
        }
    }
253252
public static function fromString($str, $encoding = self::ENCODING){
		
		if(!\is_string($str)){
			throw new \InvalidArgumentException('$str must be a PHP string');
		}
		
		if(!\is_string($encoding)){
			throw new \InvalidArgumentException('$encoding must be a string');
		}
		
		return new static($str, $encoding);
		
	}
843263
public void setEncoding(String encoding)
  {
    _charEncoding = encoding;

    String javaEncoding = Encoding.getJavaName(encoding);

    if ("ISO8859_1".equals(javaEncoding))
      _charEncoding = null;
  }
1286991
public function setType(string $contentType, ?string $charset = null): Response
	{
		$this->contentType = $contentType;

		if($charset !== null)
		{
			$this->charset = $charset;
		}

		return $this;
	}
493684
public function analyseUNB($encoding)
    {
        if (\is_array($encoding)) {
            $encoding = $encoding[0];
        }

        $this->encoding = $encoding;

        // If there's a regex defined for this character set, use it.
        /** @noinspection OffsetOperationsInspection */
        if (isset(self::$encodingToStripChars[$encoding])) {
            /** @noinspection OffsetOperationsInspection */
            $this->setStripRegex(self::$encodingToStripChars[$encoding]);
        }

        $this->unbChecked = true;
    }
910405
public function setEncoding($encoding = null)
    {
        if ($encoding !== null) {
            if (!function_exists('mb_strtolower')) {
                throw new Exception\ExtensionNotLoadedException(sprintf(
                    '%s requires mbstring extension to be loaded',
                    get_class($this)
                ));
            }

            $encoding    = strtolower($encoding);
            $mbEncodings = array_map('strtolower', mb_list_encodings());
            if (!in_array($encoding, $mbEncodings)) {
                throw new Exception\InvalidArgumentException(sprintf(
                    "Encoding '%s' is not supported by mbstring extension",
                    $encoding
                ));
            }
        }

        $this->options['encoding'] = $encoding;
        return $this;
    }
1067603
public void setRequestCharacterEncoding(java.lang.String encoding)
            throws java.io.UnsupportedEncodingException
    {
        ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
        
        if (ctx == null)
        {
            throw new UnsupportedOperationException();
        }
        
        ctx.setRequestCharacterEncoding(encoding);
    }
713290
public function setCharset($charset, $method = null)
    {
        if ($method === null) {
            $method = $this->getConfig('method');
        }

        $this->query($method . ' ' . $charset);

        return $this->getConnect()->set_charset($charset);
    }
330293
public function setEncoding($encoding)
    {
        $encoding = trim($encoding);
        if ($encoding !== '') {
            $this->flags .= " --default-encoding $encoding";
        } else {
            $this->flags = str_replace(
                ' --default-encoding ' . $this->encoding,
                '',
                $this->flags
            );
        }
        $this->encoding = $encoding;
    }
1364591
public function setEncoding($encoding)
    {
        $this->connect();
        $this->_connection->exec('SET NAMES ' . $this->_connection->quote($encoding));
    }
750473
public boolean setEncoding(String encoding) {
        for(Map.Entry<Byte, String> entry : CODE_PAGE_ENCODING.entrySet()) {
            if(entry.getValue().equalsIgnoreCase(encoding)) {
                this.fileEncoding = entry.getValue();
                return true;
            }
        }
        return false;
    }
84621
public static function hexadecimal(string $str, string $encoding = null) : bool
    {
        return static::matchesPattern($str, '^[[:xdigit:]]*$', $encoding);
    }