str_replace('Ê','',$line);
Ain't working. Is there some special string that represents that?
str_replace('Ê','',$line);
Ain't working. Is there some special string that represents that?
You need to consider the encoding of the string you want to manipulate. If that’s not encoded with the same character encoding as the file you declared that string above in is, you need to convert between both encodings.
The most common error is that either the data or the file is encoded in UTF-8 and the other in ISO 8859-1.
It's not clear if you know this, but str_replace doesn't work "in place", it returns a new string, so perhaps all you really needed was
$line=str_replace('Ê','',$line);
Another possibility is that you are looking at a Unicode combining diacritic, which is actually two unicode chars - the E and a circumflex diacritic.
I had to first convert the line to UTF-8.
mb_convert_encoding($line, "UTF-8")
So the code I ended up with is:
$line = str_replace('Ê','', mb_convert_encoding($line, "UTF-8"));
Answered my own question just to get the "solution" up instead of in a comment. Thanks Gumbo.