lithium\data\source\database\adapter\Sqlite3::encoding PHP Method

encoding() public method

Gets or sets the encoding for the connection.
public encoding ( string $encoding = null ) : mixed
$encoding string If setting the encoding, this is the name of the encoding to set, i.e. `'utf8'` or `'UTF-8'` (both formats are valid).
return mixed If setting the encoding; returns `true` on success, or `false` on failure. When getting, returns the encoding as a string.
    public function encoding($encoding = null)
    {
        $encodingMap = array('UTF-8' => 'utf8');
        if (!$encoding) {
            $query = $this->connection->query('PRAGMA encoding');
            $encoding = $query->fetchColumn();
            return ($key = array_search($encoding, $encodingMap)) ? $key : $encoding;
        }
        $encoding = isset($encodingMap[$encoding]) ? $encodingMap[$encoding] : $encoding;
        try {
            $this->connection->exec("PRAGMA encoding = \"{$encoding}\"");
            return true;
        } catch (PDOException $e) {
            return false;
        }
    }