public function query($charset, $cached = false)
    {
        $charset = Horde_String::upper($charset);

        if (isset($this->_charsets[$charset])) {
            return $this->_charsets[$charset];
        } elseif ($cached) {
            return null;
        }

        if (!$this->_baseob) {
            throw new RuntimeException(
                'Base object needs to be defined to query for charset.'
            );
        }

        /* Use a dummy search query and search for BADCHARSET response. */
        $query = new Horde_Imap_Client_Search_Query();
        $query->charset($charset, false);
        $query->ids($this->_baseob->getIdsOb(1, true));
        $query->text('a');
        try {
            $this->_baseob->search('INBOX', $query, array(
                'nocache' => true,
                'sequence' => true
            ));
            $this->_charsets[$charset] = true;
        } catch (Horde_Imap_Client_Exception $e) {
            $this->_charsets[$charset] = ($e->getCode() !== Horde_Imap_Client_Exception::BADCHARSET);
        }

        $this->notify();

        return $this->_charsets[$charset];
    }