Unicode preg_replace problem in php

I have a line

$result = "bei einer Temperatur, die etwa 20 bis 60°C unterhalb des Schmelzpunktes der kristallinen Modifikation"

which comes directly from the MySQL table. Table and php headers set as UTF-8

I want to remove the "degrees" symbol: http://en.wikipedia.org/wiki/Degree_symbol and replace it with the word "degrees" to get:

"bei einer Temperatur, die etwa 20 bis 60degreesC unterhalb des Schmelzpunktes der kristallinen Modification"

but I can't get it to work with preg_replace.

If I do this:

$result = preg_replace('/\xB0/u'," degrees ", $result ); - I get an empty string

And if I do ::

$result = preg_replace('/\u00B0/u'," degrees ", $result ); - I get the error:

Warning: preg_replace () [function.preg-replace]: Compilation error: PCRE does not support \ L, \ l, \ N, \ U or \ u at offset 1 in / var / www / html / includes / classes / redeyeTable. inc.php on line 75

I'm not very good with encodings ... what am I doing wrong here?

+3
2

$result = preg_replace('/\x{00B0}/u'," degrees ", $result );

\x{FFFF} -syntax . .

\xB0 \x{00B0}:

  • \xB0 B0 (176 decimal), (°) ISO-8859-1,
  • \x{00B0} unicode U+00B0, (°) Unicode. \xC2\xB0 UTF-8.
+22

'u', utf-8, '°' '\ u00B0' '\ xB0'?

+4

Source: https://habr.com/ru/post/1752270/


All Articles