0

I copy & paste match lists from Betfair but they have dodgy hidden characters equivalent to "Â". This means that rather than "Arsenal v Reading - Tuesday 19:45" I get "Arsenal v Reading - Tuesday 19:45".

To try and address this I do the following:

$pos = strrpos($match,"Â");
echo "pre-replace: " . $pos . "<br/>";
$trim_match = str_replace("Â","",$match);
$pos = strrpos($trim_match,"Â");
echo "post-replace: " . $pos . "<br/>";
$q2 = "insert into tab (`match`) values ('" . trim($trim_match) . "')";

The resulting output is:

pre-replace: 23
post-replace: 

But the dodgy character is still inserted. What's the best way to keep this junk data out? It is not visible when UTF-8 is set in the page or in PHPMyAdmin but the hex('l v') of the bad data is "6CC2A076" which equates to a "Â" symbol according to ASCII converters

Dird
  • 39
  • 5
  • 1
    Looks more like an encoding issue than "dodgy invisible characters" to me. – Shira Oct 23 '16 at 19:13
  • It is not about "invisible characters", but rather about incorrect encoding and/or the specification of such. See "Mojibake" in http://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored – Rick James Oct 23 '16 at 19:27
  • I ran into an issue importing CSV files.. this helped ` $data[$c] = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\x9F]/u', '', $data[$c]);` – Duane Lortie Oct 23 '16 at 19:29
  • @RickJames the problem is Chrome specific. The person copy & pasted from Firefox & the issue wasn't there, tried Chrome a 2nd time & the problem returned. Will just make it a rule that people use a real browser rather than Chrome =) – Dird Oct 23 '16 at 22:35
  • `C2A0` is a form of space that usually comes from MS Word. – Rick James Oct 24 '16 at 02:01
  • hmm interesting. He was pasting to Excel for modification & then to the site for input. The C2A0 only appeared when going Chrome -> Excel -> Chrome though, not Firefox -> Excel -> Firefox. Will see if any issues occur on Wednesday when he does a more lengthy input again using FF – Dird Oct 24 '16 at 07:38
  • If I added
    would it ignore "Â" characters on insert?
    – Dird Oct 24 '16 at 08:49

0 Answers0