Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: utf-8 encode, htmlentities giving weird results

Tags:

html

php

utf-8

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?

like image 262
user460847 Avatar asked May 09 '26 14:05

user460847


1 Answers

You are probably not specifying UTF-8 as the character set for the htmlentities() operation.

like image 177
Pekka Avatar answered May 11 '26 04:05

Pekka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!