Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP convert htmentities to latin with euro sign

I have a script that converts UTF8 to htmlentities. The result for the euro sign is &#8364. I am trying to convert this back into latin (ISO-8859-15) which I believe has the euro sign in it.

When I try

html_entity_decode('&#8364', ENT_QUOTES, 'ISO-8859-15');

it does not convert it to

€

How do I do this? (The final output will be a windows txt file.)

Edit ** I change the input string to make it more obvious as some people did not pick up on this in the second sentence.

like image 543
Owen Avatar asked Dec 13 '25 14:12

Owen


1 Answers

Windows does not follow the ISO charsets, it uses an older encoding:

html_entity_decode($string, ENT_QUOTES, 'CP1251');

The Euro symbol becomes \x88 there, whereas Latin-9/ISO-8859-15 would have \xA4

like image 56
mario Avatar answered Dec 16 '25 02:12

mario



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!