Gets or sets the encoding for the connection.

Parameters

  • string $encoding If setting the encoding, this is the name of the encoding to set, i.e. `'utf8'` or `'UTF-8'` (both formats are valid).

Returns

mixed If setting the encoding; returns `true` on success, or `false` on failure. When getting, returns the encoding as a string.

Source

						public function encoding($encoding = null) {
		$encodingMap = array('UTF-8' => 'utf8');

		if (!$encoding) {
			$encoding = $this->connection->querySingle('PRAGMA encoding');
			return ($key = array_search($encoding, $encodingMap)) ? $key : $encoding;
		}
		$encoding = isset($encodingMap[$encoding]) ? $encodingMap[$encoding] : $encoding;
		$this->connection->exec("PRAGMA encoding = \"{$encoding}\"");
		return $this->connection->querySingle("PRAGMA encoding");
	}