public function decodeString($string, $encoding) {
        switch ($encoding) {
            case IMAP::MESSAGE_ENC_7BIT:
                return $string;
            case IMAP::MESSAGE_ENC_8BIT:
                return quoted_printable_decode(imap_8bit($string));
            case IMAP::MESSAGE_ENC_BINARY:
                return imap_binary($string);
            case IMAP::MESSAGE_ENC_BASE64:
                return imap_base64($string);
            case IMAP::MESSAGE_ENC_QUOTED_PRINTABLE:
                return quoted_printable_decode($string);
            case IMAP::MESSAGE_ENC_OTHER:
                return $string;
            default:
                return $string;
        }
    }