Hi all,
in a string from a form post, I sometimes get characters like ő
(õ) as raw data (not masked). ( "Å‘", if Your mail program
supports this).
It appears that Mozilla converts the input automatically to ő, so I
end up with ő in my database (MSIE does not convert it).
My problem is that I need to export these data to a csv-file, where
ő is no good.
I've tried to use preg_replace_ca llback() with chr() to convert the
values back when exporting, but I get inconsistent results for this one
character (others seem to work):
------------ TEST ------------
<?php
function replaceChars( $matches )
{
return chr( $matches[1] );
}
?>
<form method="POST" action="#">
<input type="text" name="test">
</form>
<pre>
raw: <?=$_POST['test'];?>
htmlentities(): <?=htmlentities ( $_POST['test'] );?>
chr: <?=preg_replace _callback( "/&#([0-9]+);/",
replaceChars,
$_POST['test'] );
?>
&#337;: ő
chr(337): <?=chr(337);? >
</pre>
------------ /TEST ------------
Am I making a dumb mistake? Is the value in &#(int); not the value for
the chr()-argument?
Thanks,
Rudi
in a string from a form post, I sometimes get characters like ő
(õ) as raw data (not masked). ( "Å‘", if Your mail program
supports this).
It appears that Mozilla converts the input automatically to ő, so I
end up with ő in my database (MSIE does not convert it).
My problem is that I need to export these data to a csv-file, where
ő is no good.
I've tried to use preg_replace_ca llback() with chr() to convert the
values back when exporting, but I get inconsistent results for this one
character (others seem to work):
------------ TEST ------------
<?php
function replaceChars( $matches )
{
return chr( $matches[1] );
}
?>
<form method="POST" action="#">
<input type="text" name="test">
</form>
<pre>
raw: <?=$_POST['test'];?>
htmlentities(): <?=htmlentities ( $_POST['test'] );?>
chr: <?=preg_replace _callback( "/&#([0-9]+);/",
replaceChars,
$_POST['test'] );
?>
&#337;: ő
chr(337): <?=chr(337);? >
</pre>
------------ /TEST ------------
Am I making a dumb mistake? Is the value in &#(int); not the value for
the chr()-argument?
Thanks,
Rudi
Comment