1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5
* An open source application development framework for PHP 5.1.6 or newer
8
* @author ExpressionEngine Dev Team
9
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
10
* @license http://codeigniter.com/user_guide/license.html
11
* @link http://codeigniter.com
16
// ------------------------------------------------------------------------
21
* Provides support for UTF-8 environments
23
* @package CodeIgniter
24
* @subpackage Libraries
26
* @author ExpressionEngine Dev Team
27
* @link http://codeigniter.com/user_guide/libraries/utf8.html
34
* Determines if UTF-8 support is to be enabled
37
function __construct()
39
log_message('debug', "Utf8 Class Initialized");
44
preg_match('/./u', 'é') === 1 // PCRE must support UTF-8
45
AND function_exists('iconv') // iconv must be installed
46
AND ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled
47
AND $CFG->item('charset') == 'UTF-8' // Application charset must be UTF-8
50
log_message('debug', "UTF-8 Support Enabled");
52
define('UTF8_ENABLED', TRUE);
54
// set internal encoding for multibyte string functions if necessary
55
// and set a flag so we don't have to repeatedly use extension_loaded()
56
// or function_exists()
57
if (extension_loaded('mbstring'))
59
define('MB_ENABLED', TRUE);
60
mb_internal_encoding('UTF-8');
64
define('MB_ENABLED', FALSE);
69
log_message('debug', "UTF-8 Support Disabled");
70
define('UTF8_ENABLED', FALSE);
74
// --------------------------------------------------------------------
79
* Ensures strings are UTF-8
85
function clean_string($str)
87
if ($this->_is_ascii($str) === FALSE)
89
$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
95
// --------------------------------------------------------------------
98
* Remove ASCII control characters
100
* Removes all ASCII control characters except horizontal tabs,
101
* line feeds, and carriage returns, as all others can cause
108
function safe_ascii_for_xml($str)
110
return remove_invisible_characters($str, FALSE);
113
// --------------------------------------------------------------------
118
* Attempts to convert a string to UTF-8
122
* @param string - input encoding
125
function convert_to_utf8($str, $encoding)
127
if (function_exists('iconv'))
129
$str = @iconv($encoding, 'UTF-8', $str);
131
elseif (function_exists('mb_convert_encoding'))
133
$str = @mb_convert_encoding($str, 'UTF-8', $encoding);
143
// --------------------------------------------------------------------
148
* Tests if a string is standard 7-bit ASCII or not
154
function _is_ascii($str)
156
return (preg_match('/[^\x00-\x7F]/S', $str) == 0);
159
// --------------------------------------------------------------------
164
/* End of file Utf8.php */
165
/* Location: ./system/core/Utf8.php */
b'\\ No newline at end of file'