public function charset($encoding = null) { if (!is_null($encoding)) { $ct = $this->content_type() ? $this->content_type() : \Mime\type('HTML'); $this->headers['Content-Type'] = "{$ct}; charset={$encoding}"; } if (!isset($this->headers['Content-Type'])) { return null; } $content_type = explode(';', $this->headers['Content-Type']); $charset = explode('=', !empty($content_type[1]) ? $content_type[1] : ''); return !empty($charset[1]) ? $charset[1] : null; }
private function assign_default_content_type_and_charset() { $ct = $this->response->content_type(); $cs = $this->response->charset(); $this->response->content_type(!empty($ct) ? $ct : \Mime\type('HTML')); $this->response->charset(!empty($cs) ? $cs : self::$default_charset); }
public function test_default_for_html() { $this->get('render_default_for_html'); $this->assertEquals(\Mime\type('HTML'), $this->response->content_type()); $this->assertEquals("utf-8", $this->response->charset()); }