[dev] [commit] r953 - phplib
automailer at dexonline.ro
automailer at dexonline.ro
Fri Aug 23 14:50:48 EEST 2013
Author: cata
Date: Fri Aug 23 14:50:47 2013
New Revision: 953
Log:
Replace preg_replace(.../e...) with preg_replace_callback. The former is deprecated in PHP 5.0.
Modified:
phplib/AdminStringUtil.php
Modified: phplib/AdminStringUtil.php
==============================================================================
--- phplib/AdminStringUtil.php Fri Aug 23 03:12:55 2013 (r952)
+++ phplib/AdminStringUtil.php Fri Aug 23 14:50:47 2013 (r953)
@@ -291,6 +291,10 @@
return $word;
}
+ private static function _unicodeReplace($matches) {
+ return self::chr(hexdec($matches[0]));
+ }
+
/**
* Replace shorthand notations like ~a with Unicode symbols like ă.
* These are convenience symbols the user might type in, but we don't
@@ -298,7 +302,7 @@
*/
static function shorthandToUnicode($s) {
// Replace \abcd with the Unicode character 0xABCD
- $s = preg_replace('/\\\\([\dabcdefABCDEF]{4})/e', "self::chr(hexdec('$1'))", $s);
+ $s = preg_replace_callback('/\\\\([\dabcdefABCDEF]{4,5})/', 'self::_unicodeReplace', $s);
// A bit of a hack: We should not replace \~e with \ĕ, therefore we isolate
// the \~ compound first and restore it at the end.
@@ -403,13 +407,15 @@
return self::minimalInternalToHtml($s);
}
+ private static function _ordReplace($matches) {
+ return '&#x' . dechex(self::ord($matches[0])) . ';';
+ }
+
static function xmlizeRequired($s) {
// Escape <, > and &
$s = htmlspecialchars($s, ENT_NOQUOTES);
// Replace backslashed characters with their XML escape code
- $s = preg_replace('/\\\\(.)/e',
- "'&#x' . dechex(self::ord('$1')) . ';'",
- $s);
+ $s = preg_replace_callback('/\\\\(.)/', 'self::_ordReplace', $s);
return $s;
}
More information about the Dev
mailing list