unicode preg_replace problem in php

后端 未结 2 1039
囚心锁ツ
囚心锁ツ 2020-12-18 10:47

I\'ve got the string

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

wh

2条回答
  •  孤城傲影
    2020-12-18 11:13

    Use

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

    Please see here for more information on the \x{FFFF}-syntax.

    It's important to note the difference between \xB0 and \x{00B0}:

    • \xB0 denotes a single character with hex-code B0 (176 decimal) which is the degree symbol (°) in ISO-8859-1 for example
    • \x{00B0} denotes the unicode codepoint U+00B0 which describes the degree symbol (°) in the unicode system. This codepoint will be encoded using two bytes \xC2\xB0 when using UTF-8 encoding.

提交回复
热议问题