Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Parsing Problem -   and Â

Tags:

When I try to parse some html that has   sprinkled through it and then echo it, the   "turns into" this character: Â. Also, html_entity_decode() and str_replace() doesn't change it.

Why is this happening? How can I remove the Â's?

like image 492
Pauly Dee Avatar asked Dec 23 '10 01:12

Pauly Dee


People also ask

What is parsing error in PHP?

Parse errors are caused by misused or missing symbols in a syntax. The compiler catches the error and terminates the script. Parse errors are caused by: Unclosed brackets or quotes. Missing or extra semicolons or parentheses.

How do I fix parse error syntax error?

A parse error: syntax error, unexpected appears when the PHP interpreter detects a missing element. Most of the time, it is caused by a missing curly bracket “}”. To solve this, it will require you to scan the entire file to find the source of the error.

What is parse error?

A parse error is an error message you sometimes get on Android devices when an app fails to install. The message itself is not very specific, and there are a lot of problems that can cause it.


1 Answers

The non-breaking space exist in UTF-8 of two bytes: 0xC2 and 0xA0.

When those bytes are represented in ISO-8859-1 (a single-byte encoding) instead of UTF-8 (a multi-byte encoding) then those bytes becomes respectively the characters  and another non-breaking space .

Apparently you're parsing the HTML using UTF-8 and echoing the results using ISO-8859-1. To fix this problem, you need to either parse HTML using ISO-8859-1 or echo the results using UTF-8. I'd recommend to use UTF-8 all the way. Go through the PHP UTF-8 cheatsheet to align it all out.

like image 80
BalusC Avatar answered Sep 30 '22 19:09

BalusC