exit;
}
-$registry->setCharset('utf-8');
$gallery_id = processDirectory($dir);
if (!$keepEmpties) {
$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
}
}
-// Set charset to UTF-8 for most flexible conversion between email charset and
-// backend charset.
-$registry->setCharsetEnvironment('UTF-8');
-
// Read and parse the message.
$messages = array();
$imap = @imap_open(sprintf('{%s:%d/%s}%s',
$params = array_merge(array(
'charset' => $registry->getCharset(),
'email_charset' => $registry->getEmailCharset(),
- 'external_charset' => $registry->getExternalCharset(),
'temp' => Horde::getTempDir()
), $params);
*/
public function getCharset($original = false)
{
- /* Get cached results. */
- $cacheKey = intval($original);
- $charset = $this->_cachedCharset($cacheKey);
- if (!is_null($charset)) {
- return $charset;
- }
-
if ($original) {
- $charset = empty($this->nlsconfig['charsets'][$GLOBALS['language']])
+ return empty($this->nlsconfig['charsets'][$GLOBALS['language']])
? 'ISO-8859-1'
: $this->nlsconfig['charsets'][$GLOBALS['language']];
- } elseif ($GLOBALS['browser']->hasFeature('utf') &&
- (Horde_Util::extensionExists('iconv') ||
- Horde_Util::extensionExists('mbstring'))) {
- $charset = 'UTF-8';
- }
-
- if (is_null($charset)) {
- $charset = $this->getExternalCharset();
- }
-
- $this->_cachedCharset($cacheKey, $charset);
-
- return $charset;
- }
-
- /**
- * Returns the current charset of the environment
- *
- * @return string The character set that should be used with the current
- * locale settings.
- */
- public function getExternalCharset()
- {
- /* Get cached results. */
- $charset = $this->_cachedCharset(2);
- if (!is_null($charset)) {
- return $charset;
- }
-
- $lang_charset = setlocale(LC_ALL, 0);
- if ((strpos($lang_charset, ';') === false) &&
- (strpos($lang_charset, '/') === false)) {
- $lang_charset = explode('.', $lang_charset);
- if ((count($lang_charset) == 2) && !empty($lang_charset[1])) {
- $this->_cachedCharset(2, $lang_charset[1]);
- return $lang_charset[1];
- }
}
-
- return empty($this->nlsconfig['charsets'][$GLOBALS['language']])
- ? 'ISO-8859-1'
- : $this->nlsconfig['charsets'][$GLOBALS['language']];
+ return 'UTF-8';
}
/**
}
/**
- * Sets the UI charset.
- *
- * In general, the applied charset is automatically determined by browser
- * language and browser capabilities and there's no need to manually call
- * setCharset. However for headless (RPC) operations the charset may be
- * set manually to ensure correct character conversion in the backend.
- *
- * @param string $charset The new UI charset.
- */
- public function setCharset($charset)
- {
- $this->_cachedCharset(0, $charset);
- }
-
- /**
- * Sets the charset and reloads the whole NLS environment.
- *
- * When setting the charset, the gettext catalogs have to be reloaded too,
- * to match the new charset, among other things. This method takes care of
- * all this.
- *
- * @param string $charset The new UI charset.
- */
- public function setCharsetEnvironment($charset)
- {
- unset($GLOBALS['language']);
- $this->setCharset($charset);
- $this->setLanguageEnvironment();
- }
-
- /**
* Sets the language.
*
* @param string $lang The language abbreviation.
}
$GLOBALS['language'] = $lang;
- /* First try language with the current charset. */
- $lang_charset = $lang . '.' . $this->getCharset();
- if ($lang_charset != setlocale(LC_ALL, $lang_charset)) {
- /* Next try language with its default charset. */
- $charset = empty($this->nlsconfig['charsets'][$lang])
- ? 'ISO-8859-1'
- : $this->nlsconfig['charsets'][$lang];
- $lang_charset = $lang . '.' . $charset;
- $this->_cachedCharset(0, $charset);
- if ($lang_charset != setlocale(LC_ALL, $lang_charset)) {
- /* At last try language solely. */
- $lang_charset = $lang;
- setlocale(LC_ALL, $lang_charset);
- }
- }
-
+ $lang_charset = $lang . '.UTF-8';
+ setlocale(LC_ALL, $lang_charset);
@putenv('LC_ALL=' . $lang_charset);
@putenv('LANG=' . $lang_charset);
@putenv('LANGUAGE=' . $lang_charset);
$app,
$this->get('fileroot', $app) . '/locale'
);
- Horde_String::setDefaultCharset($this->getCharset());
}
/**
* DEFAULT: NONE
* 'email_charset' - (string) The default email charset.
* DEFAULT: NONE
- * 'external_charset' - (string) The default external charset.
- * DEFAULT: NONE
* 'temp' - (string) [REQUIRED] Location of temporary directory.
* </pre>
*
$this->_params = array_merge(array(
'charset' => null,
'email_charset' => null,
- 'external_charset' => null,
), $params);
}
if ($errno == 0) {
throw new Horde_Crypt_Exception(_("Connection refused to the public keyserver."));
} else {
- throw new Horde_Crypt_Exception(sprintf(_("Connection refused to the public keyserver. Reason: %s (%s)"), Horde_String::convertCharset($errstr, $this->_params['external_charset']), $errno));
+ $charset = 'UTF-8';
+ $lang_charset = setlocale(LC_ALL, 0);
+ if ((strpos($lang_charset, ';') === false) &&
+ (strpos($lang_charset, '/') === false)) {
+ $lang_charset = explode('.', $lang_charset);
+ if ((count($lang_charset) == 2) && !empty($lang_charset[1])) {
+ $charset = $lang_charset[1];
+ }
+ }
+ throw new Horde_Crypt_Exception(sprintf(_("Connection refused to the public keyserver. Reason: %s (%s)"), Horde_String::convertCharset($errstr, $charset), $errno));
}
}
require_once $values['config'];
}
- Horde_Nls::setCharset('utf-8');
-
if (!empty($conf['kolab']['filter']['locale_path'])
&& !empty($conf['kolab']['filter']['locale'])) {
Horde_Nls::setTextdomain('Kolab_Filter', $conf['kolab']['filter']['locale_path'], Horde_Nls::getCharset());
*/
require_once 'Horde/Autoloader.php';
-$registry->setCharset('utf-8');
-
/** Generate the format handler */
$format = Horde_Kolab_Format::factory('Xml', 'Event');
}
}
-$registry->setCharset('utf-8');
-
/** Generate the format handler */
$format = Horde_Kolab_Format::factory('Xml', 'String');
extends PHPUnit_Framework_TestCase
{
/**
- * Set up testing.
- *
- * @return NULL
- */
- protected function setUp()
- {
- $GLOBALS['registry']->setCharset('utf-8');
- }
-
- /**
* Test storing single mail addresses.
*
* @return NULL
class Horde_Kolab_Format_Integration_EventTest
extends PHPUnit_Framework_TestCase
{
-
- /**
- * Set up testing.
- *
- * @return NULL
- */
- protected function setUp()
- {
- $GLOBALS['registry']->setCharset('utf-8');
- Horde_String::setDefaultCharset('iso-8859-1');
- }
-
-
/**
* Test for https://www.intevation.de/roundup/kolab/issue3525
*
extends PHPUnit_Framework_TestCase
{
/**
- * Set up testing.
- *
- * @return NULL
- */
- protected function setUp()
- {
- $GLOBALS['registry']->setCharset('utf-8');
- }
-
- /**
* Test retrieving the document name.
*
* @return NULL
class Horde_Kolab_Format_Integration_PreferencesTest
extends PHPUnit_Framework_TestCase
{
-
- /**
- * Set up testing.
- *
- * @return NULL
- */
- protected function setUp()
- {
- $GLOBALS['registry']->setCharset('utf-8');
- }
-
/**
* Test preferences format conversion.
*
$this->markTestSkipped('The Horde_Date_Recurrence class is missing.');
}
- $GLOBALS['registry']->setCharset('utf-8');
-
$this->_oldTimezone = date_default_timezone_get();
date_default_timezone_set('Europe/Berlin');
}
extends PHPUnit_Framework_TestCase
{
/**
- * Set up testing.
- *
- * @return NULL
- */
- protected function setUp()
- {
- $GLOBALS['registry']->setCharset('utf-8');
- }
-
-
- /**
* Check the preparation of the basic XML structure
*
* @return NULL
require_once 'Horde/Kolab/Resource/Reply.php';
require_once 'Horde/Kolab/Resource/Freebusy.php';
-require_once 'Horde/String.php';
-Horde_String::setDefaultCharset('utf-8');
-
// What actions we can take when receiving an event request
define('RM_ACT_ALWAYS_ACCEPT', 'ACT_ALWAYS_ACCEPT');
define('RM_ACT_REJECT_IF_CONFLICTS', 'ACT_REJECT_IF_CONFLICTS');
public function testGetNamespaceReturnsNamespaceHandler()
{
- $GLOBALS['registry']->setCharset('UTF8');
$driver = new Horde_Kolab_Storage_Driver_Cclient(
$this->group,
array()
public function testGetNamespaceReturnsExpectedNamespaces()
{
- $GLOBALS['registry']->setCharset('UTF8');
$driver = new Horde_Kolab_Storage_Driver_Cclient(
$this->group,
array()
public function testGetNamespaceReturnsNamespaceHandler()
{
- $GLOBALS['registry']->setCharset('UTF8');
$driver = new Horde_Kolab_Storage_Driver_Imap(
$this->_getNamespaceMock(),
$this->group,
public function testGetNamespaceReturnsExpectedNamespaces()
{
- $GLOBALS['registry']->setCharset('UTF8');
$driver = new Horde_Kolab_Storage_Driver_Imap(
$this->_getNamespaceMock(),
$this->group,
public function testGetNamespaceReturnsNamespaceHandler()
{
- $GLOBALS['registry']->setCharset('UTF8');
$driver = new Horde_Kolab_Storage_Driver_Mock(
$this->group,
array()
public function testGetNamespaceReturnsExpectedNamespaces()
{
- $GLOBALS['registry']->setCharset('UTF8');
$driver = new Horde_Kolab_Storage_Driver_Mock(
$this->group,
array()
public function testGetNamespaceReturnsNamespaceHandler()
{
- $GLOBALS['registry']->setCharset('UTF8');
$driver = new Horde_Kolab_Storage_Driver_Pear(
$this->_getNamespaceMock(),
$this->group,
public function testGetNamespaceReturnsExpectedNamespaces()
{
- $GLOBALS['registry']->setCharset('UTF8');
$driver = new Horde_Kolab_Storage_Driver_Pear(
$this->_getNamespaceMock(),
$this->group,
public function testFolderTitleConvertsUtf7()
{
- $GLOBALS['registry']->setCharset('UTF8');
foreach ($this->_getNamespaces() as $namespace) {
$name = Horde_String::convertCharset('äöü', 'UTF8', 'UTF7-IMAP');
$folder = $this->_getFolder('INBOX/' . $name, $namespace);
public function testSetnameConvertsToUtf7()
{
- $GLOBALS['registry']->setCharset('UTF8');
foreach ($this->_getNamespaces() as $namespace) {
$folder = $this->_getFolder(null, $namespace);
$folder->restore($this->_storage, $this->_connection);
return;
}
- /** @todo: FIXME -> required for namespace handling */
- $GLOBALS['registry']->setCharset('UTF8');
-
/** Setup group handler */
require_once 'Horde/Group.php';
require_once 'Horde/Group/mock.php';
class Horde_Rpc_Jsonrpc extends Horde_Rpc
{
/**
- * Constructor.
- *
- * @param array $config A hash containing any additional configuration or
- * connection parameters this class might need.
- */
- function __construct($request, $params = array())
- {
- parent::__construct($request, $params);
- $GLOBALS['registry']->setCharsetEnvironment('UTF-8');
- }
-
- /**
* Returns the Content-Type of the response.
*
* @return string The MIME Content-Type of the RPC response.
*/
public function __construct($request, $params = array())
{
- $GLOBALS['registry']->setCharset('UTF-8');
-
parent::__construct($request, $params);
if (!empty($params['allowedTypes'])) {
}
/**
- * Sets the charset.
- *
- * All data passed to the backend uses this charset and data returned from
- * the backend must use this charset, too.
- *
- * @param string $charset A valid charset.
- */
- function setCharset($charset)
- {
- parent::setCharset($charset);
-
- $GLOBALS['registry']->setCharset($this->getCharset());
- Horde_String::setDefaultCharset($this->getCharset());
- }
-
- /**
* Sets the user used for this session.
*
* @param string $user A user name.
if ($syncml_backend_driver == 'Horde') {
require_once dirname(__FILE__) . '/../../../lib/Application.php';
Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true, 'session_control' => 'none'));
- Horde_String::setDefaultCharset('UTF-8');
- $registry->setCharset('UTF-8');
}
if (!empty($testsetuponly)) {
*
* @var string
*/
- static protected $_charset = 'iso-8859-1';
+ static protected $_charset = 'UTF-8';
/**
* lower() cache.
static protected $_uppers = array();
/**
- * Sets a default charset that the methods will use if none is explicitly
- * specified.
- *
- * @param string $charset The charset to use as the default one.
- */
- static public function setDefaultCharset($charset)
- {
- self::$_charset = $charset;
- if (Horde_Util::extensionExists('mbstring')) {
- $old_error = error_reporting(0);
- mb_regex_encoding(self::_mbstringCharset($charset));
- error_reporting($old_error);
- }
- }
-
- /**
* Converts a string from one charset to another.
*
* Works only if either the iconv or the mbstring extension
'/%r/' => $h->getValue('date'),
/* Date as ddd, dd mmm yyyy. */
- '/%d/' => Horde_String::convertCharset(strftime("%a, %d %b %Y", $udate), $GLOBALS['registry']->getExternalCharset()),
+ '/%d/' => Horde_String::convertCharset(strftime("%a, %d %b %Y", $udate), 'UTF-8'),
/* Date in locale's default. */
- '/%x/' => Horde_String::convertCharset(strftime("%x", $udate), $GLOBALS['registry']->getExternalCharset()),
+ '/%x/' => Horde_String::convertCharset(strftime("%x", $udate), 'UTF-8'),
/* Date and time in locale's default. */
- '/%c/' => Horde_String::convertCharset(strftime("%c", $udate), $GLOBALS['registry']->getExternalCharset()),
+ '/%c/' => Horde_String::convertCharset(strftime("%c", $udate), 'UTF-8'),
/* Message-ID. */
'/%m/' => $message_id,
$text = (substr($GLOBALS['language'], 0, 2) == 'en') ? strtolower(strftime('-%b-%Y', $last_maintenance)) : strftime('-%m-%Y', $last_maintenance);
- return $folder . Horde_String::convertCharset($text, $GLOBALS['registry']->getExternalCharset(), 'UTF7-IMAP');
+ return $folder . Horde_String::convertCharset($text, 'UTF-8', 'UTF7-IMAP');
}
}
$registry->expects($this->any())
->method('getCharset')
->will($this->returnCallback(array($this, '_registryGetCharset')));
- $registry->expects($this->any())
- ->method('setCharset')
- ->will($this->returnCallback(array($this, '_registrySetCharset')));
$GLOBALS['registry'] = $registry;
$GLOBALS['conf']['server']['name'] = 'localhost';
return $this->_registryCharset;
}
- public function _registrySetCharset($charset)
- {
- $this->_registryCharset = $charset;
- }
-
/* Begin tests */
public function testAcceptingAnInvitationResultsInReplySent()
require_once dirname(__FILE__) . '/lib/Application.php';
Horde_Registry::appInit('kronolith', array('authentication' => 'none', 'session_control' => 'none'));
-// We want to always generate UTF-8 iCalendar data.
-$registry->setCharset('UTF-8');
-
// Determine the username to show free/busy time for.
$cal = Horde_Util::getFormData('c');
$user = Horde_Util::getFormData('u');
}
}
-// Set charset to UTF-8 for most flexible conversion between email charset and
-// backend charset.
-$registry->setCharsetEnvironment('UTF-8');
-
// Read and parse the message.
if (empty($mail['user'])) {
$result = Whups_Mail::processMail($cli->readStdin(), $info);