protected static function ctcpUnquote($msg)
    {
        // CTCP-level unquoting
        $quoting = array(
            "\\a"   => "\001",
            "\\\\"  => "\\",
            "\\"    => "",  // Ignore quoting character
                            // for invalid sequences.
        );
        $msg = strtr($msg, $quoting);

        // Low-level unquoting
        $quoting = array(
            "\0200"     => "\000",
            "\020n"     => "\n",
            "\020r"     => "\r",
            "\020\020"  => "\020",
            "\020"      => "",  // Ignore quoting character
                                // for invalid sequences.
        );
        $msg = strtr($msg, $quoting);
        return $msg;
    }