I'm trying to get data from a POST form. When the user inputs "habláis"
, it shows up in view source as just "habláis"
. I want to convert this to "habláis"
for purposes of string comparison, but both utf8_encode()
and htmlentities()
are outputting habláis
, and htmlspecialchars()
does nothing. I would use str_replace
but it won't recognize the á when it searches the string.
I'm using a charset of utf-8 consistently across pages. Any idea what's going on?
You are probably not specifying UTF-8 as the character set for the htmlentities()
operation.
I'm not sure if this is your problem, but are you calling htmlentities
with the UTF-8 parameter? I ask because that's not its default:
Like htmlspecialchars(), it takes an optional third argument charset which defines character set used in conversion. Presently, the ISO-8859-1 character set is used as the default.
So you might want to try calling your function like this:
$output = htmlentities($input, ENT_COMPAT, 'UTF-8');
Does this solve your problem?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.