diff --git a/app/config/core.php b/app/config/core.php index 7e3e40a07..516b59ad6 100644 --- a/app/config/core.php +++ b/app/config/core.php @@ -41,6 +41,10 @@ * In development mode, you need to click the flash message to continue. */ Configure::write('debug', 2); +/** + * Application wide charset encoding + */ + Configure::write('App.encoding', 'UTF-8'); /** * To configure CakePHP *not* to use mod_rewrite and to * use CakePHP pretty URLs, remove these .htaccess diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index 2a812ab2b..c100a6110 100644 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -273,7 +273,10 @@ class EmailComponent extends Object{ * @access public */ function startup(&$controller) { - $this->Controller = & $controller; + $this->Controller =& $controller; + if (Configure::read('App.encoding') !== null) { + $this->charset = Configure::read('App.encoding'); + } } /** * Send an email using the specified content, template and layout diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php index 6e2b70350..afffdd9e6 100644 --- a/cake/libs/controller/components/request_handler.php +++ b/cake/libs/controller/components/request_handler.php @@ -520,9 +520,15 @@ class RequestHandlerComponent extends Object { * @see RequestHandlerComponent::respondAs() */ function renderAs(&$controller, $type) { + $options = array('charset' => 'UTF-8'); + + if (Configure::read('App.encoding') !== null) { + $options = array('charset' => Configure::read('App.encoding')); + } + if ($type == 'ajax') { $controller->layout = $this->ajaxLayout; - return $this->respondAs('html', array('charset' => 'UTF-8')); + return $this->respondAs('html', $options); } $controller->ext = '.ctp'; @@ -535,7 +541,7 @@ class RequestHandlerComponent extends Object { $controller->layoutPath = $type; if (in_array($type, array_keys($this->__requestContent))) { - $this->respondAs($type); + $this->respondAs($type, $options); } $helper = ucfirst($type); diff --git a/cake/libs/view/helpers/xml.php b/cake/libs/view/helpers/xml.php index 8ae5d1e4a..0afafe824 100644 --- a/cake/libs/view/helpers/xml.php +++ b/cake/libs/view/helpers/xml.php @@ -88,6 +88,9 @@ class XmlHelper extends AppHelper { * @return string XML header */ function header($attrib = array()) { + if (Configure::read('App.encoding') !== null) { + $this->encoding = Configure::read('App.encoding'); + } $attrib = array_merge(array('version' => '1.0', 'encoding' => $this->encoding), $attrib); return $this->output('<' . '?xml' . $this->__composeAttributes($attrib) . ' ?' . '>'); } diff --git a/cake/libs/xml.php b/cake/libs/xml.php index 335119918..986df8668 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -506,6 +506,10 @@ class XML extends XMLNode { } } + if (Configure::read('App.encoding') !== null) { + $this->encoding = Configure::read('App.encoding'); + } + foreach ($options as $key => $val) { switch ($key) { case 'version':