By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,408 Members | 1,840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,408 IT Pros & Developers. It's quick & easy.

convert the euro and pound sign

P: n/a
hi there,

it seems as if i cant convert the euro and pound sign to their html
equivalents.

i tried
eregi_replace("", "€", $haystack);
eregi_replace("", "£", $haystack);

as well as
str_replace("€", "", $haystack);
str_replace("£", "", $haystack);

to the script:
the values are coming from a http form post.
i thought the the problem could be maybe some wacko encoding that is
done because of the form.

any ideas??

muchas gracias in advance
rob

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
> hi there,

it seems as if i can´t convert the euro and pound sign to their html
equivalents.

i tried
eregi_replace("€", "€", $haystack);
eregi_replace("£", "£", $haystack);

as well as
str_replace("€", "€", $haystack);
str_replace("£", "£", $haystack);

to the script:
the values are coming from a http form post.
i thought the the problem could be maybe some wacko encoding that is
done because of the form.

any ideas??

muchas gracias in advance
rob

Hi rob,

1. Check if you're editing your file with the same encoding that how the
file is displayed. If not, try to force the file encoding with a special
header like <?xml version="1.0" encoding="iso-8859-15"?>
2. Some browsers don't understand &euro; and &pound;, try changing them to
their numeric equivalent (I don't know them but it must look like {)
--
Alexandre Lahure
Point 52, Solutions Internet "Ready to Start"
http://www.point52.com/

"Computers are like air conditioners,
They don't work when you open windows"
Jul 17 '05 #2

P: n/a
Alexandre Lahure wrote:
hi there,

it seems as if i can´t convert the euro and pound sign to their html
equivalents.

i tried
eregi_replace("€", "&euro;", $haystack);
eregi_replace("£", "&pound;", $haystack);

as well as
str_replace("&euro;", "€", $haystack);
str_replace("&pound;", "£", $haystack);

to the script:
the values are coming from a http form post.
i thought the the problem could be maybe some wacko encoding that is
done because of the form.

any ideas??

muchas gracias in advance
rob


Hi rob,

1. Check if you're editing your file with the same encoding that how the
file is displayed. If not, try to force the file encoding with a special
header like <?xml version="1.0" encoding="iso-8859-15"?>
2. Some browsers don't understand &euro; and &pound;, try changing them
to their numeric equivalent (I don't know them but it must look like
{)

hi alexandre,

the problem more the fact that i can´t "grab" them rather than the display.
meaning - ereg_replace finds neither the euro sign (€) nor the pound
sign (£). so i don´t even get to the point where &euro; could be displayed.
the process again:

form post -> ereg_replace -> write to db

but as said the ereg_replace doesn´t find the euros and pounds to
convert them.

do you know what i mean?

all the best
rob

Jul 17 '05 #3

P: n/a
> hi alexandre,

the problem more the fact that i can´t "grab" them rather than the
display.
meaning - ereg_replace finds neither the euro sign (€) nor the pound
sign (£). so i don´t even get to the point where &euro; could be
displayed.
the process again:

form post -> ereg_replace -> write to db

but as said the ereg_replace doesn´t find the euros and pounds to
convert them.

do you know what i mean?

all the best
rob


I had a similar problem with people filling my forms under windows and who
cut&pasted text from Notepad to the HTML inputs or textareas. The text
typed in Notepad wasn't iso-8859-15 but windows-cp125? so I wasn't able to
see special characters like euro.
All I managed to do is tell them to not cut&paste into forms...
Sorry

--
Alexandre Lahure
Point 52, Solutions Internet "Ready to Start"
http://www.point52.com/

"Computers are like air conditioners,
They don't work when you open windows"
Jul 17 '05 #4

P: n/a
On Fri, 07 Nov 2003 14:16:53 +0100, Robert Zierhofer <ro*@starbugg.de> wrote:
it seems as if i cant convert the euro and pound sign to their html
equivalents.

i tried
eregi_replace("", "&euro;", $haystack);
eregi_replace("", "&pound;", $haystack);

as well as
str_replace("&euro;", "", $haystack);
str_replace("&pound;", "", $haystack);

to the script:
the values are coming from a http form post.
i thought the the problem could be maybe some wacko encoding that is
done because of the form.

any ideas??


The main gotcha with the Euro is that it's a different code point under
different character sets.

iso-8859-1 doesn't have it at all - it was created before the Euro existed.

iso-8859-15 has it as chr(164), replacing the universal currency symbol that
was in that code point in iso-8859-1.

To make it worse, Windows codepage 1252 has it in chr(128).

In Unicode it's U+20AC (i.e. 20AC in hexadecimal; the actual representation
depends on the encoding, e.g. UTF-8).

Some charts of the character sets here:

http://en.wikipedia.org/wiki/ISO-8859-1
http://en.wikipedia.org/wiki/ISO_8859-15

So - check your input data to see whether it's using chr(164) or chr(128) - or
something else.

Then check your script to see whether the literal you have there is encoded
with the same code point. If not - try using chr(164) or chr(128) as
appropriate.

The headers in your post indicate you posted using:

Content-Type: text/plain; charset=windows-1252; format=flowed
^^^^^^^^^^^^^^^^^^^^

So the Euro in your message must be chr(128); copying it into a hex editor
confirms that. I bet your data is encoded with an iso-8859 based character set,
so it's chr(164).

Not sure about the though since that doesn't differ between the commonly
used character sets; chr(163).

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.