Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

convert the euro and pound sign

3 views
Skip to first unread message

Robert Zierhofer

unread,
Nov 7, 2003, 8:16:53 AM11/7/03
to
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

Alexandre Lahure

unread,
Nov 7, 2003, 8:43:11 AM11/7/03
to


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 &#123;)


--
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"

Robert Zierhofer

unread,
Nov 7, 2003, 8:56:12 AM11/7/03
to
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
> &#123;)
>
>

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

Alexandre Lahure

unread,
Nov 7, 2003, 10:23:51 AM11/7/03
to
> 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

Andy Hassall

unread,
Nov 7, 2003, 11:02:55 AM11/7/03
to

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)

0 new messages