Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 3 commits into from
This page is out of date. Refresh to see the latest.
View
6 src/Joomla/Application/Web.php
@@ -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;
@@ -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))
{
@@ -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 . '" />';
View
1  src/Joomla/Application/composer.json
@@ -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",
View
29 src/Joomla/String/String.php
@@ -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.
*
Something went wrong with that request. Please try again.