473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

convert the euro and pound sign

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

Jul 17 '05 #1
4 25897
> 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
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
> 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
On Fri, 07 Nov 2003 14:16:53 +0100, Robert Zierhofer <ro*@starbugg.de> wrote:
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??


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SPG | last post by:
Hi, I am haveing some problems with getting the correct XML response from a Servlet. I have data that contains the euro sign ( 0x80 = ?) and the string I am trying to print out to the response...
4
by: ben | last post by:
Hi all, I have a simple PHP page that takes values from a form and puts them in a database (MySQL). The code is in a file test.php, which I have typed in at the bottom of this post (please...
5
by: Waldy | last post by:
Hi there, I am using the .Net XML Serialization classes to create XML strings. This has been working fine up until the point that one of the strings contained a pound sterling symbol. The...
7
by: kingski | last post by:
Any idea about this ? http://www.developerfusion.co.uk/forums/thread/114379/#114379 "Can any one help me as i am building a shopping cart and it supports multiple currencies but while sending...
0
by: kingski | last post by:
Any idea about this? http://www.developerfusion.co.uk/forums/thread/114379/#114379 "Can any one help me as i am building a shopping cart and it supports multiple currencies but while sending...
4
by: Kim | last post by:
Inserting a record through sql (asp, msaccess textfield), inserting the euro sign "?" shows up like a questionmark "?" in the output. I have <%@ LANGUAGE="VBSCRIPT" CodePage=28591 LCID=2077 %at...
9
by: ballygowanboy | last post by:
ok, so i've my front end shop code almost working, the quantity and price all add up........ now i need to add a curency conversion function, euro (default), dollar, and uk pound. right, i'm not...
3
by: Georg Weiler | last post by:
Hi, I have a database PostgreSQL entry that includes the string € which is the euro sign. When I retrieve the string through a PHP SQL statement and then echo the result to the browser, it...
1
by: AAGazer | last post by:
Hi, For some reason str_ireplace and str_replace do not remove the euro symbol. This is the code snip it: $mremoveArray=array("€","£"); $tString=”15,00€”; ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.