protected function findCharset($struct)
    {
        if (isset($struct->parameters)) {
            foreach ($struct->parameters as $param) {
                if (strtolower($param->attribute) === 'charset') {
                    return strtoupper($param->value);
                }
            }
        }
        if (isset($struct->dparameters)) {
            foreach ($struct->dparameters as $param) {
                if (strtolower($param->attribute) === 'charset') {
                    return strtoupper($param->value);
                }
            }
        }

        return '';
    }