开发者

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.


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


According to this page, you are correct: ISO-8859-15 does indeed support the EURO SIGN character.

When you say "it does not convert it" are you sure it doesn't? Because properly encoding the character is only half of the work - you have to inform the client application (i.e., the browser) what encoding the data is encoded with, so that it may properly decode the bytes into characters.

You'll need a line of code that looks something like this

ini_set( 'default_charset', 'ISO-8859-15' );

Or this

header( 'Content-Type: text/html; charset=ISO-8859-15' );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜