CapitanFindus CapitanFindus - 6 months ago 53
AngularJS Question

html_entity_decode after filter_var not working as expected

I guess I'm having a problem with

, that probably has a simple solution which I've not found yet. This is my problem, I have this string:

L'evento dell'anno

Which when I save into my db, gets filtered with
and outputs this:

L'evento dell'anno

Now, when I retrieve it directly from PHP inside a page, I don't need no encoding / decoding functions, and text shows as expected, as I wrote it initially, but, when I load it from AngularJS ( version 1)
it doesn't replace chars, if I print the object values I see all those HTML entities ( I think they are, I'm not sure ).

This is my AngularJS code part:

$http.get(php_data.ajax_url, {
params: {
action: 'get-sostenitore',
get_id: show_id
}).then(function (response) {
// Handle data

// Handle data
part only prints results, nothing more.

Didn't work, so I added this PHP part:

$decoded_vars = array_map(function ($val) {
return html_entity_decode($val, ENT_COMPAT,'UTF-8');
}, get_object_vars($object));

Doesn't work too.

I've tried
, but converts special letters too ( à, è, etc... ).

I've been searching here on StackOverflow for about 2 hours, and I've found some results, like this, this, or this (I've found another full guide to encoding / decoding here on SA, but I didn't find it again ), but none of them solved my problem.

The funny thing is that I've tried pasting my string on this online tool and it shows correctly.

Could it be an AngularJS problem? I'm becoming mad for this, but I'm sure it has a really simple solution


after hours of searching, I've found a solution, which is angular-sanitize, which I've found here. So, to solve my problem I've just added ngSanitize as module dependancy.

Anyway, thanks your all your answers, I've found something interesting in each one of them which I will keep in mind.