Search code examples
phpunicodeescapingdouble-quotessingle-quotes

PHP: Convert single-quoted string into double-quoted


I need to convert string with unicode \xCODEs into regular string. The issue is that string which I have as input seems to be single-quoted.

Is there any way to convert single-quoted string into double?

Here's some code for better understanding:

$s1 = '(single quotes): Conductivity @ 20\xc3\x82\xc2\xb0C';
$s2 = "(double quotes): Conductivity @ 20\xc3\x82\xc2\xb0C";

echo "<br>";
echo iconv("UTF-8", "ISO-8859-1//IGNORE", $s1);
echo "<br>";
echo iconv("UTF-8", "ISO-8859-1//IGNORE", $s2);

will output:

(single quotes): Conductivity @ 20\xc3\x82\xc2\xb0C
(double quotes): Conductivity @ 20°C

Thanks in advance!


Solution

  • It turns that I was looking for stripcslashes

    Many thanks @mario!