Fix #2799 by adding conditional PCRE UTF-8 support to CI_URI::filter_uri()

Also did a tiny micro-optimization in the Utf8 class.
diff --git a/system/core/URI.php b/system/core/URI.php
index 3d6d202..c83b7a7 100644
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -320,7 +320,7 @@
 	 */
 	public function filter_uri($str)
 	{
-		if ( ! empty($str) && ! empty($this->_permitted_uri_chars) && ! preg_match('/^['.$this->_permitted_uri_chars.']+$/i', $str))
+		if ( ! empty($str) && ! empty($this->_permitted_uri_chars) && ! preg_match('/^['.$this->_permitted_uri_chars.']+$/i'.(UTF8_ENABLED ? 'u' : ''), $str))
 		{
 			show_error('The URI you submitted has disallowed characters.', 400);
 		}
diff --git a/system/core/Utf8.php b/system/core/Utf8.php
index a78616d..828a8ae 100644
--- a/system/core/Utf8.php
+++ b/system/core/Utf8.php
@@ -66,7 +66,7 @@
 		}
 
 		if (
-			@preg_match('/./u', 'é') === 1	// PCRE must support UTF-8
+			defined('PREG_BAD_UTF8_ERROR')	// PCRE must support UTF-8
 			&& function_exists('iconv')	// iconv must be installed
 			&& MB_ENABLED === TRUE		// mbstring must be enabled
 			&& $charset === 'UTF-8'		// Application charset must be UTF-8
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index a1dc3c1..4712ed8 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -391,7 +391,8 @@
 
    -  :doc:`URI Library <libraries/uri>` changes include:
 
-      -  Renamed method ``_filter_uri()`` to ``filter_uri()`` and removed the ``preg_quote()`` call from it.
+      -  Added conditional PCRE UTF-8 support to the "invalid URI characters" check and removed the ``preg_quote()`` call from it to allow more flexibility.
+      -  Renamed method ``_filter_uri()`` to ``filter_uri()``.
       -  Changed private methods to protected so that MY_URI can override them.
       -  Renamed internal method ``_parse_cli_args()`` to ``_parse_argv()``.
       -  Renamed internal method ``_detect_uri()`` to ``_parse_request_uri()``.