<?php
/**
* @brief Dotclear helper methods
*
* @package Dotclear
* @subpackage Core
*
* @copyright Olivier Meunier & Association Dotclear
* @copyright GPL-2.0-only
*/
if (!defined('DC_RC_PATH')) {
return;
}
class dcUtils
{
/**
* Static function that returns user's common name given to his
* <var>user_id</var>, <var>user_name</var>, <var>user_firstname</var> and
* <var>user_displayname</var>.
*
* @param string $user_id The user identifier
* @param string $user_name The user name
* @param string $user_firstname The user firstname
* @param string $user_displayname The user displayname
*
* @return string The user cn.
*/
public static function getUserCN($user_id, $user_name, $user_firstname, $user_displayname)
{
if (!empty($user_displayname)) {
return $user_displayname;
}
if (!empty($user_name)) {
if (!empty($user_firstname)) {
return $user_firstname . ' ' . $user_name;
}
return $user_name;
} elseif (!empty($user_firstname)) {
return $user_firstname;
}
return $user_id;
}
/**
* Cleanup a list of IDs
*
* @param mixed $ids The identifiers
*
* @return array
*/
public static function cleanIds($ids)
{
$clean_ids = [];
if (!is_array($ids) && !($ids instanceof ArrayObject)) {
$ids = [$ids];
}
foreach ($ids as $id) {
if (is_array($id) || ($id instanceof ArrayObject)) {
$clean_ids = array_merge($clean_ids, self::cleanIds($id));
} else {
$id = abs((int) $id);
if (!empty($id)) {
$clean_ids[] = $id;
}
}
}
return $clean_ids;
}
/**
* Compare two versions with option of using only main numbers.
*
* @param string $current_version Current version
* @param string $required_version Required version
* @param string $operator Comparison operand
* @param boolean $strict Use full version
*
* @return boolean True if comparison success
*/
public static function versionsCompare($current_version, $required_version, $operator = '>=', $strict = true)
{
if ($strict) {
$current_version = preg_replace('!-r(\d+)$!', '-p$1', $current_version);
$required_version = preg_replace('!-r(\d+)$!', '-p$1', $required_version);
} else {
$current_version = preg_replace('/^([0-9\.]+)(.*?)$/', '$1', $current_version);
$required_version = preg_replace('/^([0-9\.]+)(.*?)$/', '$1', $required_version);
}
return (bool) version_compare($current_version, $required_version, $operator);
}
private static function appendVersion(string $src, ?string $v = ''): string
{
return $src .
(strpos($src, '?') === false ? '?' : '&') .
'v=' . (defined('DC_DEV') && DC_DEV === true ? md5(uniqid()) : ($v ?: DC_VERSION));
}
public static function cssLoad($src, $media = 'screen', $v = null)
{
$escaped_src = html::escapeHTML($src);
if ($v !== null) {
$escaped_src = dcUtils::appendVersion($escaped_src, $v);
}
return '<link rel="stylesheet" href="' . $escaped_src . '" type="text/css" media="' . $media . '" />' . "\n";
}
public static function cssModuleLoad($src, $media = 'screen', $v = null)
{
global $core;
return self::cssLoad($core->blog->getPF($src), $media, $v);
}
public static function jsLoad($src, $v = null)
{
$escaped_src = html::escapeHTML($src);
if ($v !== null) {
$escaped_src = dcUtils::appendVersion($escaped_src, $v);
}
return '<script src="' . $escaped_src . '"></script>' . "\n";
}
public static function jsModuleLoad($src, $v = null)
{
global $core;
return self::jsLoad($core->blog->getPF($src), $v);
}
/**
* return a list of javascript variables définitions code
*
* @deprecated 2.15 use dcUtils::jsJson() and dotclear.getData()/dotclear.mergeDeep() in javascript
*
* @param array $vars The variables
*
* @return string javascript code (inside <script… ></script>)
*/
public static function jsVars($vars)
{
$ret = '<script>' . "\n";
foreach ($vars as $var => $value) {
$ret .= 'var ' . $var . ' = ' . (is_string($value) ? '"' . html::escapeJS($value) . '"' : $value) . ';' . "\n";
}
$ret .= "</script>\n";
return $ret;
}
/**
* return a javascript variable definition line code
*
* @deprecated 2.15 use dcUtils::jsJson() and dotclear.getData()/dotclear.mergeDeep() in javascript
*
* @param string $n variable name
* @param mixed $v value
*
* @return string javascript code
*/
public static function jsVar($n, $v)
{
return dcUtils::jsVars([$n => $v]);
}
public static function jsJson($id, $vars)
{
// Use echo dcUtils::jsLoad($core->blog->getPF('util.js')); to use the JS dotclear.getData() decoder in public mode
$ret = '<script type="application/json" id="' . html::escapeHTML($id) . '-data">' . "\n" .
json_encode($vars, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES) . "\n" . '</script>';
return $ret;
}
/**
* Locale specific array sorting function
*
* @param array $arr single array of strings
* @param string $ns admin/public/lang
* @param string $lang language to be used if $ns = 'lang'
*/
public static function lexicalSort(&$arr, $ns = '', $lang = 'en_US')
{
if ($ns != '') {
dcUtils::setLexicalLang($ns, $lang);
}
return usort($arr, ['dcUtils', 'lexicalSortHelper']);
}
/**
* Locale specific array sorting function (preserving keys)
*
* @param array $arr single array of strings
* @param string $ns admin/public/lang
* @param string $lang language to be used if $ns = 'lang'
*/
public static function lexicalArraySort(&$arr, $ns = '', $lang = 'en_US')
{
if ($ns != '') {
dcUtils::setLexicalLang($ns, $lang);
}
return uasort($arr, ['dcUtils', 'lexicalSortHelper']);
}
/**
* Locale specific array sorting function (sorting keys)
*
* @param array $arr single array of strings
* @param string $ns admin/public/lang
* @param string $lang language to be used if $ns = 'lang'
*/
public static function lexicalKeySort(&$arr, $ns = '', $lang = 'en_US')
{
if ($ns != '') {
dcUtils::setLexicalLang($ns, $lang);
}
return uksort($arr, ['dcUtils', 'lexicalSortHelper']);
}
public static function setLexicalLang($ns = '', $lang = 'en_US')
{
global $core;
// Switch to appropriate locale depending on $ns
switch ($ns) {
case 'admin':
// Set locale with user prefs
$user_language = $core->auth->getInfo('user_lang');
setlocale(LC_COLLATE, $user_language);
break;
case 'public':
// Set locale with blog params
$blog_language = $core->blog->settings->system->lang;
setlocale(LC_COLLATE, $blog_language);
break;
case 'lang':
// Set locale with arg
setlocale(LC_COLLATE, $lang);
break;
}
}
private static function lexicalSortHelper($a, $b)
{
return strcoll(strtolower(dcUtils::removeDiacritics($a)), strtolower(dcUtils::removeDiacritics($b)));
}
// removeDiacritics function (see https://github.com/infralabs/DiacriticsRemovePHP)
protected static $defaultDiacriticsRemovalMap = [
[
'base' => 'A',
'letters' => '/(A|Ⓐ|A|À|Á|Â|Ầ|Ấ|Ẫ|Ẩ|Ã|Ā|Ă|Ằ|Ắ|Ẵ|Ẳ|Ȧ|Ǡ|Ä|Ǟ|Ả|Å|Ǻ|Ǎ|Ȁ|Ȃ|Ạ|Ậ|Ặ|Ḁ|Ą|Ⱥ|Ɐ|[\x{0041}\x{24B6}\x{FF21}\x{00C0}\x{00C1}\x{00C2}\x{1EA6}\x{1EA4}\x{1EAA}\x{1EA8}\x{00C3}\x{0100}\x{0102}\x{1EB0}\x{1EAE}\x{1EB4}\x{1EB2}\x{0226}\x{01E0}\x{00C4}\x{01DE}\x{1EA2}\x{00C5}\x{01FA}\x{01CD}\x{0200}\x{0202}\x{1EA0}\x{1EAC}\x{1EB6}\x{1E00}\x{0104}\x{023A}\x{2C6F}])/',
],
[
'base' => 'AA',
'letters' => '/(Ꜳ|[\x{A732}])/',
],
[
'base' => 'AE',
'letters' => '/(Æ|Ǽ|Ǣ|[\x{00C6}\x{01FC}\x{01E2}])/',
],
[
'base' => 'AO',
'letters' => '/(Ꜵ|[\x{A734}])/',
],
[
'base' => 'AU',
'letters' => '/(Ꜷ|[\x{A736}])/',
],
[
'base' => 'AV',
'letters' => '/(Ꜹ|Ꜻ|[\x{A738}\x{A73A}])/',
],
[
'base' => 'AY',
'letters' => '/(Ꜽ|[\x{A73C}])/',
],
[
'base' => 'B',
'letters' => '/(B|Ⓑ|B|Ḃ|Ḅ|Ḇ|Ƀ|Ƃ|Ɓ|[\x{0042}\x{24B7}\x{FF22}\x{1E02}\x{1E04}\x{1E06}\x{0243}\x{0182}\x{0181}])/',
],
[
'base' => 'C',
'letters' => '/(C|Ⓒ|C|Ć|Ĉ|Ċ|Č|Ç|Ḉ|Ƈ|Ȼ|Ꜿ|[\x{0043}\x{24B8}\x{FF23}\x{0106}\x{0108}\x{010A}\x{010C}\x{00C7}\x{1E08}\x{0187}\x{023B}\x{A73E}])/',
],
[
'base' => 'D',
'letters' => '/(D|Ⓓ|D|Ḋ|Ď|Ḍ|Ḑ|Ḓ|Ḏ|Đ|Ƌ|Ɗ|Ɖ|Ꝺ|Ð|[\x{0044}\x{24B9}\x{FF24}\x{1E0A}\x{010E}\x{1E0C}\x{1E10}\x{1E12}\x{1E0E}\x{0110}\x{018B}\x{018A}\x{0189}\x{A779}\x{00D0}])/',
],
[
'base' => 'DZ',
'letters'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{24CF}\x{FF3A}\x{0179}\x{1E90}\x{017B}\x{017D}\x{1E92}\x{1E94}\x{01B5}\x{0224}\x{2C7F}\x{2C6B}\x{A762}])/',
],
[
'base' => 'a',
'letters' => '/(a|ⓐ|a|ẚ|à|á|â|ầ|ấ|ẫ|ẩ|ã|ā|ă|ằ|ắ|ẵ|ẳ|ȧ|ǡ|ä|ǟ|ả|å|ǻ|ǎ|ȁ|ȃ|ạ|ậ|ặ|ḁ|ą|ⱥ|ɐ|[\x{0061}\x{24D0}\x{FF41}\x{1E9A}\x{00E0}\x{00E1}\x{00E2}\x{1EA7}\x{1EA5}\x{1EAB}\x{1EA9}\x{00E3}\x{0101}\x{0103}\x{1EB1}\x{1EAF}\x{1EB5}\x{1EB3}\x{0227}\x{01E1}\x{00E4}\x{01DF}\x{1EA3}\x{00E5}\x{01FB}\x{01CE}\x{0201}\x{0203}\x{1EA1}\x{1EAD}\x{1EB7}\x{1E01}\x{0105}\x{2C65}\x{0250}])/',
],
[
'base' => 'aa',
'letters' => '/(ꜳ|[\x{A733}])/',
],
[
'base' => 'ae',
'letters' => '/(æ|ǽ|ǣ|[\x{00E6}\x{01FD}\x{01E3}])/',
],
[
'base' => 'ao',
'letters' => '/(ꜵ|[\x{A735}])/',
],
[
'base' => 'au',
'letters' => '/(ꜷ|[\x{A737}])/',
],
[
'base' => 'av',
'letters' => '/(ꜹ|ꜻ|[\x{A739}\x{A73B}])/',
],
[
'base' => 'ay',
'letters' => '/(ꜽ|[\x{A73D}])/',
],
[
'base' => 'b',
'letters' => '/(b|ⓑ|b|ḃ|ḅ|ḇ|ƀ|ƃ|ɓ|[\x{0062}\x{24D1}\x{FF42}\x{1E03}\x{1E05}\x{1E07}\x{0180}\x{0183}\x{0253}])/',
],
[
'base' => 'c',
'letters' => '/(c|ⓒ|c|ć|ĉ|ċ|č|ç|ḉ|ƈ|ȼ|ꜿ|ↄ|[\x{0063}\x{24D2}\x{FF43}\x{0107}\x{0109}\x{010B}\x{010D}\x{00E7}\x{1E09}\x{0188}\x{023C}\x{A73F}\x{2184}])/',
],
[
'base' => 'd',
'letters' => '/(d|ⓓ|d|ḋ|ď|ḍ|ḑ|ḓ|ḏ|đ|ƌ|ɖ|ɗ|ꝺ|ð|[\x{0064}\x{24D3}\x{FF44}\x{1E0B}\x{010F}\x{1E0D}\x{1E11}\x{1E13}\x{1E0F}\x{0111}\x{018C}\x{0256}\x{0257}\x{A77A}\x{00F0}])/',
],
[
'base' => 'dz',
'letters' => '/(dz|dž|[\x{01F3}\x{01C6}])/',
],
[
'base' => 'e',
'letters' => '/(e|ⓔ|e|è|é|ê|ề|ế|ễ|ể|ẽ|ē|ḕ|ḗ|ĕ|ė|ë|ẻ|ě|ȅ|ȇ|ẹ|ệ|ȩ|ḝ|ę|ḙ|ḛ|ɇ|ɛ|ǝ|[\x{0065}\x{24D4}\x{FF45}\x{00E8}\x{00E9}\x{00EA}\x{1EC1}\x{1EBF}\x{1EC5}\x{1EC3}\x{1EBD}\x{0113}\x{1E15}\x{1E17}\x{0115}\x{0117}\x{00EB}\x{1EBB}\x{011B}\x{0205}\x{0207}\x{1EB9}\x{1EC7}\x{0229}\x{1E1D}\x{0119}\x{1E19}\x{1E1B}\x{0247}\x{025B}\x{01DD}])/',
],
[
'base' => 'f',
'letters' => '/(f|ⓕ|f|ḟ|ƒ|ꝼ|[\x{0066}\x{24D5}\x{FF46}\x{1E1F}\x{0192}\x{A77C}])/',
],
[
'base' => 'g',
'letters' => '/(g|ⓖ|g|ǵ|ĝ|ḡ|ğ|ġ|ǧ|ģ|ǥ|ɠ|ꞡ|ᵹ|ꝿ|[\x{0067}\x{24D6}\x{FF47}\x{01F5}\x{011D}\x{1E21}\x{011F}\x{0121}\x{01E7}\x{0123}\x{01E5}\x{0260}\x{A7A1}\x{1D79}\x{A77F}])/',
],
[
'base' => 'h',
'letters' => '/(h|ⓗ|h|ĥ|ḣ|ḧ|ȟ|ḥ|ḩ|ḫ|ẖ|ħ|ⱨ|ⱶ|ɥ|[\x{0068}\x{24D7}\x{FF48}\x{0125}\x{1E23}\x{1E27}\x{021F}\x{1E25}\x{1E29}\x{1E2B}\x{1E96}\x{0127}\x{2C68}\x{2C76}\x{0265}])/',
],
[
'base' => 'hv',
'letters' => '/(ƕ|[\x{0195}])/',
],
[
'base' => 'i',
'letters' => '/(i|ⓘ|i|ì|í|î|ĩ|ī|ĭ|ï|ḯ|ỉ|ǐ|ȉ|ȋ|ị|į|ḭ|ɨ|ı|[\x{0069}\x{24D8}\x{FF49}\x{00EC}\x{00ED}\x{00EE}\x{0129}\x{012B}\x{012D}\x{00EF}\x{1E2F}\x{1EC9}\x{01D0}\x{0209}\x{020B}\x{1ECB}\x{012F}\x{1E2D}\x{0268}\x{0131}])/',
],
[
'base' => 'ij',
'letters' => '/(ij|[\x{0133}])/',
],
[
'base' => 'j',
'letters' => '/(j|ⓙ|j|ĵ|ǰ|ɉ|[\x{006A}\x{24D9}\x{FF4A}\x{0135}\x{01F0}\x{0249}])/',
],
[
'base' => 'k',
'letters' => '/(k|ⓚ|k|ḱ|ǩ|ḳ|ķ|ḵ|ƙ|ⱪ|ꝁ|ꝃ|ꝅ|ꞣ|[\x{006B}\x{24DA}\x{FF4B}\x{1E31}\x{01E9}\x{1E33}\x{0137}\x{1E35}\x{0199}\x{2C6A}\x{A741}\x{A743}\x{A745}\x{A7A3}])/',
],
[
'base' => 'l',
'letters' => '/(l|ⓛ|l|ŀ|ĺ|ľ|ḷ|ḹ|ļ|ḽ|ḻ|ł|ƚ|ɫ|ⱡ|ꝉ|ꞁ|ꝇ|[\x{006C}\x{24DB}\x{FF4C}\x{0140}\x{013A}\x{013E}\x{1E37}\x{1E39}\x{013C}\x{1E3D}\x{1E3B}\x{0142}\x{019A}\x{026B}\x{2C61}\x{A749}\x{A781}\x{A747}])/',
],
[
'base' => 'lj',
'letters' => '/(lj|[\x{01C9}])/',
],
[
'base' => 'm',
'letters' => '/(m|ⓜ|m|ḿ|ṁ|ṃ|ɱ|ɯ|[\x{006D}\x{24DC}\x{FF4D}\x{1E3F}\x{1E41}\x{1E43}\x{0271}\x{026F}])/',
],
[
'base' => 'n',
'letters' => '/(n|ⓝ|n|ǹ|ń|ñ|ṅ|ň|ṇ|ņ|ṋ|ṉ|ƞ|ɲ|ʼn|ꞑ|ꞥ|ŋ|[\x{006E}\x{24DD}\x{FF4E}\x{01F9}\x{0144}\x{00F1}\x{1E45}\x{0148}\x{1E47}\x{0146}\x{1E4B}\x{1E49}\x{019E}\x{0272}\x{0149}\x{A791}\x{A7A5}\x{014B}])/',
],
[
'base' => 'nj',
'letters' => '/(nj|[\x{01CC}])/',
],
[
'base' => 'o',
'letters' => '/(o|ⓞ|o|ò|ó|ô|ồ|ố|ỗ|ổ|õ|ṍ|ȭ|ṏ|ō|ṑ|ṓ|ŏ|ȯ|ȱ|ö|ȫ|ỏ|ő|ǒ|ȍ|ȏ|ơ|ờ|ớ|ỡ|ở|ợ|ọ|ộ|ǫ|ǭ|ø|ǿ|ɔ|ꝋ|ꝍ|ɵ|[\x{006F}\x{24DE}\x{FF4F}\x{00F2}\x{00F3}\x{00F4}\x{1ED3}\x{1ED1}\x{1ED7}\x{1ED5}\x{00F5}\x{1E4D}\x{022D}\x{1E4F}\x{014D}\x{1E51}\x{1E53}\x{014F}\x{022F}\x{0231}\x{00F6}\x{022B}\x{1ECF}\x{0151}\x{01D2}\x{020D}\x{020F}\x{01A1}\x{1EDD}\x{1EDB}\x{1EE1}\x{1EDF}\x{1EE3}\x{1ECD}\x{1ED9}\x{01EB}\x{01ED}\x{00F8}\x{01FF}\x{0254}\x{A74B}\x{A74D}\x{0275}])/',
],
[
'base' => 'oe',
'letters' => '/(œ|[\x{0153}])/',
],
[
'base' => 'oi',
'letters' => '/(ƣ|[\x{01A3}])/',
],
[
'base' => 'ou',
'letters' => '/(ȣ|[\x{0223}])/',
],
[
'base' => 'oo',
'letters' => '/(ꝏ|[\x{A74F}])/',
],
[
'base' => 'p',
'letters' => '/(p|ⓟ|p|ṕ|ṗ|ƥ|ᵽ|ꝑ|ꝓ|ꝕ|[\x{0070}\x{24DF}\x{FF50}\x{1E55}\x{1E57}\x{01A5}\x{1D7D}\x{A751}\x{A753}\x{A755}])/',
],
[
'base' => 'q',
'letters' => '/(q|ⓠ|q|ɋ|ꝗ|ꝙ|[\x{0071}\x{24E0}\x{FF51}\x{024B}\x{A757}\x{A759}])/',
],
[
'base' => 'r',
'letters' => '/(r|ⓡ|r|ŕ|ṙ|ř|ȑ|ȓ|ṛ|ṝ|ŗ|ṟ|ɍ|ɽ|ꝛ|ꞧ|ꞃ|[\x{0072}\x{24E1}\x{FF52}\x{0155}\x{1E59}\x{0159}\x{0211}\x{0213}\x{1E5B}\x{1E5D}\x{0157}\x{1E5F}\x{024D}\x{027D}\x{A75B}\x{A7A7}\x{A783}])/',
],
[
'base' => 's',
'letters' => '/(s|ⓢ|s|ś|ṥ|ŝ|ṡ|š|ṧ|ṣ|ṩ|ș|ş|ȿ|ꞩ|ꞅ|ẛ|ſ|[\x{0073}\x{24E2}\x{FF53}\x{015B}\x{1E65}\x{015D}\x{1E61}\x{0161}\x{1E67}\x{1E63}\x{1E69}\x{0219}\x{015F}\x{023F}\x{A7A9}\x{A785}\x{1E9B}\x{017F}])/',
],
[
'base' => 'ss',
'letters' => '/(ß|[\x{00DF}])/',
],
[
'base' => 't',
'letters' => '/(t|ⓣ|t|ṫ|ẗ|ť|ṭ|ț|ţ|ṱ|ṯ|ŧ|ƭ|ʈ|ⱦ|ꞇ|[\x{0074}\x{24E3}\x{FF54}\x{1E6B}\x{1E97}\x{0165}\x{1E6D}\x{021B}\x{0163}\x{1E71}\x{1E6F}\x{0167}\x{01AD}\x{0288}\x{2C66}\x{A787}])/',
],
[
'base' => 'th',
'letters' => '/(þ|[\x{00FE}])/',
],
[
'base' => 'tz',
'letters' => '/(ꜩ|[\x{A729}])/',
],
[
'base' => 'u',
'letters' => '/(u|ⓤ|u|ù|ú|û|ũ|ṹ|ū|ṻ|ŭ|ü|ǜ|ǘ|ǖ|ǚ|ủ|ů|ű|ǔ|ȕ|ȗ|ư|ừ|ứ|ữ|ử|ự|ụ|ṳ|ų|ṷ|ṵ|ʉ|[\x{0075}\x{24E4}\x{FF55}\x{00F9}\x{00FA}\x{00FB}\x{0169}\x{1E79}\x{016B}\x{1E7B}\x{016D}\x{00FC}\x{01DC}\x{01D8}\x{01D6}\x{01DA}\x{1EE7}\x{016F}\x{0171}\x{01D4}\x{0215}\x{0217}\x{01B0}\x{1EEB}\x{1EE9}\x{1EEF}\x{1EED}\x{1EF1}\x{1EE5}\x{1E73}\x{0173}\x{1E77}\x{1E75}\x{0289}])/',
],
[
'base' => 'v',
'letters' => '/(v|ⓥ|v|ṽ|ṿ|ʋ|ꝟ|ʌ|[\x{0076}\x{24E5}\x{FF56}\x{1E7D}\x{1E7F}\x{028B}\x{A75F}\x{028C}])/',
],
[
'base' => 'vy',
'letters' => '/(ꝡ|[\x{A761}])/',
],
[
'base' => 'w',
'letters' => '/(w|ⓦ|w|ẁ|ẃ|ŵ|ẇ|ẅ|ẘ|ẉ|ⱳ|[\x{0077}\x{24E6}\x{FF57}\x{1E81}\x{1E83}\x{0175}\x{1E87}\x{1E85}\x{1E98}\x{1E89}\x{2C73}])/',
],
[
'base' => 'x',
'letters' => '/(x|ⓧ|x|ẋ|ẍ|[\x{0078}\x{24E7}\x{FF58}\x{1E8B}\x{1E8D}])/',
],
[
'base' => 'y',
'letters' => '/(y|ⓨ|y|ỳ|ý|ŷ|ỹ|ȳ|ẏ|ÿ|ỷ|ẙ|ỵ|ƴ|ɏ|ỿ|[\x{0079}\x{24E8}\x{FF59}\x{1EF3}\x{00FD}\x{0177}\x{1EF9}\x{0233}\x{1E8F}\x{00FF}\x{1EF7}\x{1E99}\x{1EF5}\x{01B4}\x{024F}\x{1EFF}])/',
],
[
'base' => 'z',
'letters' => '/(z|ⓩ|z|ź|ẑ|ż|ž|ẓ|ẕ|ƶ|ȥ|ɀ|ⱬ|ꝣ|[\x{007A}\x{24E9}\x{FF5A}\x{017A}\x{1E91}\x{017C}\x{017E}\x{1E93}\x{1E95}\x{01B6}\x{0225}\x{0240}\x{2C6C}\x{A763}])/',
],
];
public static function removeDiacritics($str)
{
$flags = 'um';
for ($i = 0; $i < sizeof(dcUtils::$defaultDiacriticsRemovalMap); $i++) {
$str = preg_replace(
dcUtils::$defaultDiacriticsRemovalMap[$i]['letters'] . $flags,
dcUtils::$defaultDiacriticsRemovalMap[$i]['base'],
$str
);
}
return $str;
}
}