convert the euro and pound sign

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Zierhofer

    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("&e uro;", "€", $haystack);
    str_replace("&p ound;", "£", $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

    #2
    Re: convert the euro and pound sign

    > hi there,[color=blue]
    >
    > 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("&e uro;", "€", $haystack);
    > str_replace("&p ound;", "£", $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[/color]


    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"
    Call 210-825-0924 Hours Monday - Saturday By Appointment


    "Computers are like air conditioners,
    They don't work when you open windows"

    Comment

    • Robert Zierhofer

      #3
      Re: convert the euro and pound sign

      Alexandre Lahure wrote:
      [color=blue][color=green]
      >> 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("&e uro;", "€", $haystack);
      >> str_replace("&p ound;", "£", $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[/color]
      >
      >
      >
      > 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;)
      >
      >[/color]
      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

      Comment

      • Alexandre Lahure

        #4
        Re: convert the euro and pound sign

        > hi alexandre,[color=blue]
        >
        > 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[/color]

        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"
        Call 210-825-0924 Hours Monday - Saturday By Appointment


        "Computers are like air conditioners,
        They don't work when you open windows"

        Comment

        • Andy Hassall

          #5
          Re: convert the euro and pound sign

          On Fri, 07 Nov 2003 14:16:53 +0100, Robert Zierhofer <rob@starbugg.d e> wrote:
          [color=blue]
          >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??[/color]

          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:




          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 (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
          Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

          Comment

          Working...