if (! sq_is8bit($string,'iso-8859-1'))
return $string;
- $string = preg_replace("/([\201-\237])/e","'&#' . ord('\\1') . ';'",$string);
+ $string = preg_replace_callback("/([\201-\237])/",
+ create_function ('$matches', 'return \'&#\' . ord($matches[1]) . \';\';'),
+ $string);
/* I don't want to use 0xA0 (\240) in any ranges. RH73 may dislike it */
$string = str_replace("\240", ' ', $string);
- $string = preg_replace("/([\241-\377])/e","'&#' . ord('\\1') . ';'",$string);
+ $string = preg_replace_callback("/([\241-\377])/",
+ create_function ('$matches', 'return \'&#\' . ord($matches[1]) . \';\';'),
+ $string);
return $string;
}
if (! sq_is8bit($string,'us-ascii'))
return $string;
- $string = preg_replace("/([\201-\237])/e","'?'",$string);
+ $string = preg_replace("/([\201-\237])/","'?'",$string);
/* I don't want to use 0xA0 (\240) in any ranges. RH73 may dislike it */
$string = str_replace("\240", '?', $string);
- $string = preg_replace("/([\241-\377])/e","'?'",$string);
+ $string = preg_replace("/([\241-\377])/","'?'",$string);
return $string;
}
// decode six byte unicode characters
/* (i think currently there is no such symbol)
- $string = preg_replace("/([\374-\375])([\200-\277])([\200-\277])([\200-\277])([\200-\277])([\200-\277])/e",
- "'&#'.((ord('\\1')-252)*1073741824+(ord('\\2')-200)*16777216+(ord('\\3')-200)*262144+(ord('\\4')-128)*4096+(ord('\\5')-128)*64+(ord('\\6')-128)).';'",
+ $string = preg_replace_callback("/([\374-\375])([\200-\277])([\200-\277])([\200-\277])([\200-\277])([\200-\277])/",
+ create_function ('$matches', 'return \'&#\'.((ord($matches[1])-252)*1073741824+(ord($matches[2])-200)*16777216+(ord($matches[3])-200)*262144+(ord($matches[4])-128)*4096+(ord($matches[5])-128)*64+(ord($matches[6])-128)).\';\';'),
$string);
*/
// decode five byte unicode characters
/* (i think currently there is no such symbol)
- $string = preg_replace("/([\370-\373])([\200-\277])([\200-\277])([\200-\277])([\200-\277])/e",
- "'&#'.((ord('\\1')-248)*16777216+(ord('\\2')-200)*262144+(ord('\\3')-128)*4096+(ord('\\4')-128)*64+(ord('\\5')-128)).';'",
+ $string = preg_replace_callback("/([\370-\373])([\200-\277])([\200-\277])([\200-\277])([\200-\277])/",
+ create_function ('$matches', 'return \'&#\'.((ord($matches[1])-248)*16777216+(ord($matches[2])-200)*262144+(ord($matches[3])-128)*4096+(ord($matches[4])-128)*64+(ord($matches[5])-128)).\';\';'),
$string);
*/
-
+
// decode four byte unicode characters
- $string = preg_replace("/([\360-\367])([\200-\277])([\200-\277])([\200-\277])/e",
- "'&#'.((ord('\\1')-240)*262144+(ord('\\2')-128)*4096+(ord('\\3')-128)*64+(ord('\\4')-128)).';'",
+ $string = preg_replace_callback("/([\360-\367])([\200-\277])([\200-\277])([\200-\277])/",
+ create_function ('$matches', 'return \'&#\'.((ord($matches[1])-240)*262144+(ord($matches[2])-128)*4096+(ord($matches[3])-128)*64+(ord($matches[4])-128)).\';\';'),
$string);
// decode three byte unicode characters
- $string = preg_replace("/([\340-\357])([\200-\277])([\200-\277])/e",
- "'&#'.((ord('\\1')-224)*4096+(ord('\\2')-128)*64+(ord('\\3')-128)).';'",
+ $string = preg_replace_callback("/([\340-\357])([\200-\277])([\200-\277])/",
+ create_function ('$matches', 'return \'&#\'.((ord($matches[1])-224)*4096+(ord($matches[2])-128)*64+(ord($matches[3])-128)).\';\';'),
$string);
// decode two byte unicode characters
- $string = preg_replace("/([\300-\337])([\200-\277])/e",
- "'&#'.((ord('\\1')-192)*64+(ord('\\2')-128)).';'",
+ $string = preg_replace_callback("/([\300-\337])([\200-\277])/",
+ create_function ('$matches', 'return \'&#\'.((ord($matches[1])-192)*64+(ord($matches[2])-128)).\';\';'),
$string);
// remove broken unicode
// don't run encoding function, if there is no encoded characters
if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
- $string=preg_replace("/&#([0-9]+);/e","unicodetocp1251('\\1')",$string);
+ $string=preg_replace_callback("/&#([0-9]+);/", 'unicodetocp1251', $string);
return $string;
}
* Don't use it or make sure, that functions/encode/cp1251.php is
* included.
*
- * @param int $var decimal unicode value
+ * @param array $matches array with first element a decimal unicode value
* @return string cp1251 character
*/
-function unicodetocp1251($var) {
+function unicodetocp1251($matches) {
+ $var = $matches[1];
$cp1251chars=array('160' => "\xA0",
'164' => "\xA4",
// don't run encoding function, if there is no encoded characters
if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
- $string=preg_replace("/&#([0-9]+);/e","unicodetocp1255('\\1')",$string);
+ $string=preg_replace_callback("/&#([0-9]+);/",'unicodetocp1255',$string);
return $string;
}
* Don't use it or make sure, that functions/encode/cp1255.php is
* included.
*
- * @param int $var decimal unicode value
+ * @param array $matches array with first element a decimal unicode value
* @return string cp1255 character
*/
-function unicodetocp1255($var) {
+function unicodetocp1255($matches) {
+ $var = $matches[1];
$cp1255chars=array('160' => "\xA0",
'161' => "\xA1",
// don't run encoding function, if there is no encoded characters
if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
- $string=preg_replace("/&#([0-9]+);/e","unicodetocp1256('\\1')",$string);
+ $string=preg_replace_callback("/&#([0-9]+);/",'unicodetocp1256',$string);
return $string;
}
* Don't use it or make sure, that functions/encode/cp1256.php is
* included.
*
- * @param int $var decimal unicode value
+ * @param array $matches array with first element a decimal unicode value
* @return string cp1256 character
*/
-function unicodetocp1256($var) {
+function unicodetocp1256($matches) {
+ $var = $matches[1];
$cp1256chars=array('160' => "\xA0",
'162' => "\xA2",
// don't run encoding function, if there is no encoded characters
if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
- $string=preg_replace("/&#([0-9]+);/e","unicodetoiso88591('\\1')",$string);
+ $string=preg_replace_callback("/&#([0-9]+);/",'unicodetoiso88591',$string);
return $string;
}
* Don't use it or make sure, that functions/encode/iso_8859_1.php is
* included.
*
- * @param int $var decimal unicode value
+ * @param array $matches array with first element a decimal unicode value
* @return string iso-8859-1 character
*/
-function unicodetoiso88591($var) {
+function unicodetoiso88591($matches) {
+ $var = $matches[1];
if ($var < 256) {
$ret = chr ($var);
// don't run encoding function, if there is no encoded characters
if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
- $string=preg_replace("/&#([0-9]+);/e","unicodetoiso885915('\\1')",$string);
+ $string=preg_replace_callback("/&#([0-9]+);/",'unicodetoiso885915',$string);
return $string;
}
* Don't use it or make sure, that functions/encode/iso_8859_15.php is
* included.
*
- * @param int $var decimal unicode value
+ * @param array $matches array with first element a decimal unicode value
* @return string iso-8859-15 character
*/
-function unicodetoiso885915($var) {
+function unicodetoiso885915($matches) {
+ $var = $matches[1];
$iso885915chars=array('160' => "\xA0",
'161' => "\xA1",
// don't run encoding function, if there is no encoded characters
if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
- $string=preg_replace("/&#([0-9]+);/e","unicodetoiso88592('\\1')",$string);
+ $string=preg_replace_callback("/&#([0-9]+);/",'unicodetoiso88592',$string);
return $string;
}
* Don't use it or make sure, that functions/encode/iso_8859_2.php is
* included.
*
- * @param int $var decimal unicode value
+ * @param array $matches array with first element a decimal unicode value
* @return string iso-8859-2 character
*/
-function unicodetoiso88592($var) {
+function unicodetoiso88592($matches) {
+ $var = $matches[1];
$iso88592chars=array('160' => "\xA0",
'164' => "\xA4",
// don't run encoding function, if there is no encoded characters
if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
- $string=preg_replace("/&#([0-9]+);/e","unicodetoiso88597('\\1')",$string);
+ $string=preg_replace_callback("/&#([0-9]+);/",'unicodetoiso88597',$string);
return $string;
}
* Don't use it or make sure, that functions/encode/iso_8859_7.php is
* included.
*
- * @param int $var decimal unicode value
+ * @param array $matches array with first element a decimal unicode value
* @return string iso-8859-7 character
*/
-function unicodetoiso88597($var) {
+function unicodetoiso88597($matches) {
+ $var = $matches[1];
$iso88597chars=array('160' => "\xA0",
'163' => "\xA3",
// don't run encoding function, if there is no encoded characters
if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
- $string=preg_replace("/&#([0-9]+);/e","unicodetoiso88599('\\1')",$string);
+ $string=preg_replace_callback("/&#([0-9]+);/",'unicodetoiso88599',$string);
return $string;
}
* Don't use it or make sure, that functions/encode/iso_8859_9.php is
* included.
*
- * @param int $var decimal unicode value
+ * @param array $matches array with first element a decimal unicode value
* @return string iso-8859-9 character
*/
-function unicodetoiso88599($var) {
+function unicodetoiso88599($matches) {
+ $var = $matches[1];
$iso88599chars=array('160' => "\xA0",
'161' => "\xA1",
// don't run encoding function, if there is no encoded characters
if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
- $string=preg_replace("/&#([0-9]+);/e","unicodetokoi8r('\\1')",$string);
+ $string=preg_replace_callback("/&#([0-9]+);/",'unicodetokoi8r',$string);
return $string;
}
* Don't use it or make sure, that functions/encode/koi8_r.php is
* included.
*
- * @param int $var decimal unicode value
+ * @param array $matches array with first element a decimal unicode value
* @return string koi8-r character
*/
-function unicodetokoi8r($var) {
+function unicodetokoi8r($matches) {
+ $var = $matches[1];
$koi8rchars=array('160' => "\x9A",
'169' => "\xBF",
// don't run encoding function, if there is no encoded characters
if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
- $string=preg_replace("/&#([0-9]+);/e","unicodetokoi8u('\\1')",$string);
+ $string=preg_replace_callback("/&#([0-9]+);/",'unicodetokoi8u',$string);
return $string;
}
* Don't use it or make sure, that functions/encode/koi8_u.php is
* included.
*
- * @param int $var decimal unicode value
+ * @param array $matches array with first element a decimal unicode value
* @return string koi8-u character
*/
-function unicodetokoi8u($var) {
+function unicodetokoi8u($matches) {
+ $var = $matches[1];
$koi8uchars=array('160' => "\x9A",
'169' => "\xBF",
// don't run encoding function, if there is no encoded characters
if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
- $string=preg_replace("/&#([0-9]+);/e","unicodetotis620('\\1')",$string);
+ $string=preg_replace_callback("/&#([0-9]+);/",'unicodetotis620',$string);
return $string;
}
* Don't use it or make sure, that functions/encode/tis_620.php is
* included.
*
- * @param int $var decimal unicode value
+ * @param array $matches array with first element a decimal unicode value
* @return string tis-620 character
*/
-function unicodetotis620($var) {
+function unicodetotis620($matches) {
+ $var = $matches[1];
$tis620chars=array('3585' => "\xA1",
'3586' => "\xA2",
// don't run encoding function, if there is no encoded characters
if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
- $string=preg_replace("/&#([0-9]+);/e","unicodetousascii('\\1')",$string);
+ $string=preg_replace_callback("/&#([0-9]+);/",'unicodetousascii',$string);
return $string;
}
* Don't use it or make sure, that functions/encode/us_ascii.php is
* included.
*
- * @param int $var decimal unicode value
+ * @param array $matches array with first element a decimal unicode value
* @return string us-ascii character
*/
-function unicodetousascii($var) {
+function unicodetousascii($matches) {
+ $var = $matches[1];
if ($var < 128) {
$ret = chr ($var);
// don't run encoding function, if there is no encoded characters
if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
- $string=preg_replace("/&#([0-9]+);/e","unicodetoutf8('\\1')",$string);
+ $string=preg_replace_callback("/&#([0-9]+);/",'unicodetoutf8',$string);
return $string;
}
* Don't use it or make sure, that functions/encode/utf_8.php is
* included.
*
- * @param int $var decimal unicode value
+ * @param array $matches array with first element a decimal unicode value
* @return string utf8 character
*/
-function unicodetoutf8($var) {
+function unicodetoutf8($matches) {
+ $var = $matches[1];
if ($var < 128) {
$ret = chr ($var);
break;
case 'Q':
$replace = str_replace('_', ' ', $res[4]);
- $replace = preg_replace('/=([0-9a-f]{2})/ie', 'chr(hexdec("\1"))',
+ $replace = preg_replace_callback('/=([0-9a-f]{2})/i',
+ create_function ('$matches', 'return chr(hexdec($matches[1]));'),
$replace);
if ($utfencode) {
if ($can_be_encoded) {