/** * Recompose a UTF string * * @param string $str Unchecked UTF string * @param integer $pos Position of the first UTF char (in bytes) * @param integer $len Length of the string (in bytes) * @param array &$qc Quick-check array, passed by reference but never modified * @param array &$decomp_map Decomposition mapping, passed by reference but never modified * @return string The string, validated and recomposed * * @access private */ function recompose($str, $pos, $len, &$qc, &$decomp_map) { global $utf_canonical_comp; // Load the canonical composition table if (!isset($utf_canonical_comp)) { global $phpbb_root_path, $phpEx; include $phpbb_root_path . 'includes/utf/data/utf_canonical_comp.' . $phpEx; } return utf_normalizer::recompose($str, $pos, $len, $qc, $decomp_map); }
/** * Validate and normalize a UTF string to NFKC * * @param string &$str Unchecked UTF string * @return string The string, validated and in normal form */ public static function nfkc(&$str) { $pos = strspn($str, UTF8_ASCII_RANGE); $len = strlen($str); if ($pos == $len) { // ASCII strings return immediately return; } if (!isset($GLOBALS['utf_nfkc_qc'])) { include(IP_ROOT_PATH . 'includes/utf/data/utf_nfkc_qc.' . PHP_EXT); } if (!isset($GLOBALS['utf_compatibility_decomp'])) { include(IP_ROOT_PATH . 'includes/utf/data/utf_compatibility_decomp.' . PHP_EXT); } $str = utf_normalizer::recompose($str, $pos, $len, $GLOBALS['utf_nfkc_qc'], $GLOBALS['utf_compatibility_decomp']); }
/** * Validate and normalize a UTF string to NFKC * * @param string &$str Unchecked UTF string * @return string The string, validated and in normal form */ static function nfkc(&$str) { $pos = strspn($str, UTF8_ASCII_RANGE); $len = strlen($str); if ($pos == $len) { // ASCII strings return immediately return; } if (!isset($GLOBALS['utf_nfkc_qc'])) { global $mangareader_root_path; include($mangareader_root_path . 'includes/utf/data/utf_nfkc_qc.php'); } if (!isset($GLOBALS['utf_compatibility_decomp'])) { global $mangareader_root_path; include($mangareader_root_path . 'includes/utf/data/utf_compatibility_decomp.php'); } $str = utf_normalizer::recompose($str, $pos, $len, $GLOBALS['utf_nfkc_qc'], $GLOBALS['utf_compatibility_decomp']); }