Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Remove final jimport() call from Application package. #101

Merged
merged 3 commits into from Mar 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/Joomla/Application/Web.php
Expand Up @@ -11,6 +11,7 @@
use Joomla\Uri\Uri;
use Joomla\Date\Date;
use Joomla\Input\Input;
use Joomla\String\String;
use Joomla\Session\Session;
use Joomla\Registry\Registry;

Expand Down Expand Up @@ -273,9 +274,6 @@ protected function respond()
*/
public function redirect($url, $moved = false)
{
// Import library dependencies.
jimport('phputf8.utils.ascii');

// Check for relative internal links.
if (preg_match('#^index\.php#', $url))
{
Expand Down Expand Up @@ -322,7 +320,7 @@ public function redirect($url, $moved = false)
else
{
// We have to use a JavaScript redirect here because MSIE doesn't play nice with utf-8 URLs.
if (($this->client->engine == Web\Client::TRIDENT) && !utf8_is_ascii($url))
if (($this->client->engine == Web\Client::TRIDENT) && !String::is_ascii($url))
{
$html = '<html><head>';
$html .= '<meta http-equiv="content-type" content="text/html; charset=' . $this->charSet . '" />';
Expand Down
1 change: 1 addition & 0 deletions src/Joomla/Application/composer.json
Expand Up @@ -10,6 +10,7 @@
"joomla/date": "dev-master",
"joomla/input": "dev-master",
"joomla/session": "dev-master",
"joomla/string": "dev-master",
"joomla/registry": "dev-master",
"joomla/uri": "dev-master",
"joomla/filesystem": "dev-master",
Expand Down
29 changes: 29 additions & 0 deletions src/Joomla/String/String.php
Expand Up @@ -117,6 +117,35 @@ public static function increment($string, $style = 'default', $n = 0)
return $string;
}


/**
* Tests whether a string contains only 7bit ASCII bytes.
* You might use this to conditionally check whether a string
* needs handling as UTF-8 or not, potentially offering performance
* benefits by using the native PHP equivalent if it's just ASCII e.g.;
*
* <code>
* if (String::is_ascii($someString))
* {
* // It's just ASCII - use the native PHP version
* $someString = strtolower($someString);
* }
* else
* {
* $someString = String::strtolower($someString);
* }
* </code>
*
* @param string $string The string to test.
*
* @return boolean True if the string is all ASCII
*/
public static function is_ascii($str)
{
// Search for any bytes which are outside the ASCII range...
return (preg_match('/(?:[^\x00-\x7F])/', $str) !== 1);
}

/**
* UTF-8 aware alternative to strpos.
*
Expand Down