Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #101 from dongilbert/staging

Remove final jimport() call from Application package.
  • Loading branch information...
commit 18a2fd95f5869c73033aeee653fd493cc7c74af8 2 parents b58ef07 + 9d4ac07
@eddieajau eddieajau authored
View
6 src/Joomla/Application/Web.php
@@ -10,6 +10,7 @@
use Joomla\Uri\Uri;
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
@@ -9,6 +9,7 @@
"php": ">=5.3.10",
"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.
*
Please sign in to comment.
Something went wrong with that request. Please try again.